Re: [Scheme-reports] Please make internal BEGIN a splicing form
Andre van Tonder 25 Apr 2011 06:57 UTC
On Mon, 25 Apr 2011, Alex Shinn wrote:
> On Mon, Apr 25, 2011 at 12:51 AM, Andre van Tonder <andre@het.brown.edu> 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
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports