Hi Mark,

>
> > So what we actually need is a procedure of
> > two arguments: `(ellipsis?  e ctx)' returns `#t' if the identifier `e'
> > is the current ellipsis in the lexical environment of the identifier
> > `ctx'.
>
> Hmm.  I don't actually see a need for the second argument, do you?  I
> can't think of a case where I'd want to 'e' to be different from 'ctx'.
>

Let's assume we are writing a macro that reimplements syntax (or some
variation thereof) and which has to check whether identifiers are ellipses.
For example, the following could be given:

(with-ellipsis e
  (my-syntax a e)

Now, this could be a result of a macro expansion and e could carry
different marks than with-syntax or my-syntax. This is why I have been
thinking that one also needs the lexical context of my-syntax and not only
the context of e.

The issue I raised has to do with the fact that syntax-objects do not
> contain their lexical environments.  The 'wrap' of a syntax-object
> essentially only contains a set of deferred substitutions to be applied
> to the identifiers within the syntax object, if they end up outside of a
> quoted datum in the expanded code.  The wrap is primarily an efficiency
> hack, but also enables the implementation of 'datum->syntax'.

If we eliminated the efficiency hack, and also 'datum->syntax', we could
> implement identifiers more simply as a record containing two symbols:
> the original symbol, and the symbol after all substitutions have been
> applied.  Identifiers found within quoted datums would be interpreted as
> their original symbols, and identifiers found anywhere else would be
> interpreted as the symbols with the substitutions applied.
>

Thanks for the explanation. I have been toying with my own implementation
of the syntax-case system. In my implementation the (shared) lexical
environments are part of the wraps (so the identifiers are in some way
self-contained).

Anyway, as I wrote above, the good news is that we can get 'r' from the
> dynamic environment.
>

Will ellipsis? also work outside of macros? Say, what would be the result
of the following (run-time) code?

(with-syntax e
  (ellipsis? #'e)


> I have a draft patch to add a unary predicate to (system syntax), but
> I'd like to work on it a bit more before posting it.
>

That's great news! Thanks!

Best,

Marc

P.S.: By the way, the module (system syntax) and in particular the
procedure syntax-local-binding has already helped me a lot because I needed
to attach extra information to symbols and Guile doesn't (yet) support
Chez's define-property (well, this would be another feature request).

Reply via email to