[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New SRFI 0 draft

This page is part of the web mail archives of SRFI 0 from before July 7th, 2015. The new archives for SRFI 0 contain all messages, not just those from before July 7th, 2015.

>> is Mike Sperber
> is Marc Feeley

>> - Import of feature implementations (IMHO) *needs* to be made
>>   explicit.  Scheme implementations which load additional features
>>   on-demand (such Scheme 48) would *have* to say NO to any feature
>>   requested.
> That is not true. [...]

It certainly is true for Scheme 48.  Scheme 48 has many extensions
to Scheme, but none of them are available by default.  A make-available-
on-demand approach requires that the demands be known before the code
is processed.  COND-EXPAND makes this very difficult.  Consider the
following program:

  (and-let* ((x (assq a (read))))
    (display x))

  (cond-expand (srfi-2 'okay))		; need AND-LET*

The initial pass of the Scheme 48 compiler macro-expands the top-level
forms in order, expanding each only enough to see if it is a definition
or syntax definition.  By the time the compiler sees the COND-EXPAND,
it will have already classified the AND-LET* form as a call.  I suppose
I could add an initial pass to find all the COND-EXPAND forms, but that
is both too much work and still error prone, because macros can expand
into uses of COND-EXPAND.

>> - By now several Scheme implementors have expressed their preference
>>   for a separate configuration language.  Richard, of course, Will,
>>   Donovan, and the Rice folks.  Is there a strong reason *not* to do
>>   it this way?
> Yes, freedom of implementation.

I think you have this backwards.  A great advantage of a separate
configuration language is that it puts minimal restrictions on the
implementation.  The configuration language I proposed is trivial
to implement in the presence of a fixed feature set and possible to
implement in the presence of a module system.  COND-EXPAND requires
a fixed feature set.

Here is a PROGRAM macro that implements the configuration language
in terms of COND-EXPAND:

 (define-syntax program
   (syntax-rules (requires files code feature-cond)
     ((program (requires feature-id ...)
               more ...)
      (begin (cond-expand ((and feature-id ...) 'okay))
             (program more ...)))
     ((program (files filename ...)
               more ...)
      (begin (load filename) ...
             (program more ...)))
     ((program (code stuff ...)
               more ...)
      (begin stuff ...
             (program more ...)))
     ((program (feature-cond clauses ...)
               more ...)
      (begin (cond-expand clauses ...)
             (program more ...)))))

(I left out the READER-SYNTAX clause because I agree with Will
 Clinger that it should be discussed separately.)

                                     -Richard Kelsey