Email list hosting service & mailing list manager

sequence? Jim Rees (07 Jan 2017 12:02 UTC)
Re: sequence? Marc Nieper-Wißkirchen (07 Jan 2017 12:33 UTC)

Re: sequence? Marc Nieper-Wißkirchen 07 Jan 2017 12:33 UTC

Am 07.01.2017 um 13:02 schrieb Jim Rees:

> "If the transformer spec is a keyword, the keyword bound to the
> transformer spec essentially becomes an alias to the syntactic keyword
> keyword. (Keyword may also be one of the core syntactic keywords like
> lambda, if, define.) The same holds if the transformer spec is a macro
> use that eventually expands into a (possibly empty) sequence of
> multiple definitions followed by the keyword (possibly bound by the
> introduced definitions)."
>
> Could you elaborate more or give examples of the what the second
> sentence implies?     Is this sequence you refer to a (begin ...)
> form?   If so, and if it contains definitions as you suggest, what is
> their scope?    Can those definitions include both variable and syntax
> definitions?
Yes, by sequence I mean a sequence introduced by `begin'. For example:

(define-syntax foo
   (begin
     (define-syntax bar lambda)
     bar))

In principle, these definitions can contain variable and syntax
definitions; for the purpose of writing custom macro transformers,
however, syntax definitions is all that is needed.

The scope of these definitions is described in the SRFI:

In case of (define-syntax foo (...)), the definitions introduced by
(...) are in the same scope as the definition of foo itself.

In case of (let-syntax ((foo (...))) ...), the definitions introduced by
(...) are in a scope between the outer and the inner scope of
let-syntax. For example,

(let-syntax ((foo (begin (define-syntax bar lambda) bar))) ...)

is equivalent to

(let () (define-syntax bar lambda) (let-syntax ((foo bar)) ...)).

In case of (letrec-syntax ((foo (...))) ...), the definitions introduced
by (...) are in the scope of the bindings of letrec-syntax (i.e. in the
scope where foo is defined).

The reasons for these rules are:

1) This SRFI should be implementable in R7RS-small.
2) The rules should be as intuitive as possible.
3) Sophisticated custom macro transformers (as the one in SRFI 148)
should be implementable in R7RS-small.

--

Marc