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

Re: [Scheme-reports] Please make internal BEGIN a splicing form

On Mon, 25 Apr 2011, Alex Shinn wrote:

> On Mon, Apr 25, 2011 at 12:51 AM, Andre van Tonder <andre@x> wrote:
>> On Sun, 24 Apr 2011, Jussi Piitulainen wrote:
>> Why can't internal BEGIN be a splicing form as in R6RS?  There is
>> no good reason why
>>    (let ()
>>      (begin (define-syntax .....)
>>             (define ............)
>>             <expression>)
>> shouldn't work fine.
> Internal BEGIN is a splicing form, and you can use it to
> expand multiple syntax definitions or normal definitions,
> optionally expanded from other macros like define-record-type.

But is there a rationale for not allowing internal BEGIN to include both 
definitions /and/ expressions as in the above example?

> The rationale for requiring the syntax definitions appear
> before normal definitions is in part compatibility with the
> R5RS restriction that definitions precede expressions,

Gien that R5RS has no intrernal syhtax definitions, R5RS compatibility does 
not require that syntax definitions precede ordinary definitions.

> and in part because I didn't want to touch the R6RS
> semantics with a 10 foot pole. The example given in
> R6RS is:
>  (let ()
>    (define even?
>      (lambda (x)
>        (or (= x 0) (odd? (- x 1)))))
>    (define-syntax odd?
>      (syntax-rules ()
>        ((odd?  x) (not (even? x)))))
>    (even? 10))                               => #t
> which is a terrible programming style to
> encourage, and may be prohibitively difficult
> for some existing R5RS implementations.

Requiring that macros precede their use would accomplish the same goal 
(of making implementation easier and excluding your even/odd example from the 
set of portable programs) without imposing the restriction that syntax 
definitions precede ordinary defitions.  Again, this restriction would make 
impossible very reasonable programs like

    (let ()
      (define-record-type foo ....)
      (define-record-type bar ....)

if e.g., define-record-type is implemented as in SRFI 9 where it includes both 
syntax and ordinary definitions.

Scheme-reports mailing list