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

Re: Opaque syntax objects

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

On Sun, 14 Aug 2005, [ISO-8859-1] Jens Axel Søgaard wrote:

What should I do if I want to give a piece of (expanded) syntax the
same source information as, say, the macro call?

There can be a primitive for that.  E.g.,
  annotate : (syntax-object, syntax-object) -> syntax-object
In the hash-table, this would insert a new entry for the pair representing the second syntax object, copying the annotation of the first.

Of course. Syntax objects are still ordinary pairs. No change to car/cdr is required. The hash table with source information is kept separately.

Hmm. How do you represent identifiers?

The same way, once you give them a wrap to give them separate identities.

I believe with-syntax behaves that way in order to be (more) compatible
with the psyntax-implementation. Note that the source location
information for stx-expr in

 (with-syntax ((pattern stx-expr) ...) expr)

is taken from stx-expr, when stx-expr is not returning a list. That
is the source location is still tracked.

Do you know what location is assigned when stx-expr is a list?

As an aside, it is sometimes easy to throw away too much information when using the destructuring idiom. For example, in

  (define-syntax let1
    (lambda (form)
      (syntax-case form ()
        ((_ ((i e) ...) e1 e2 ...)
         (syntax (let ((i e) ...) e1 e2 ...))))))

it is unlikely that most implementations would keep the location of the input subnode ((i e) ...) in the result.