It's not at all clear that you can write unbound? in R6RS... I too was
confused by the words "template identifier" which appear in only two
or three places out of nowhere in describing datum->syntax.

In Aziz's definition of unbound? he used the suggestive name
"empty-ctxt", but I don't think a "context" is part of the R6RS
ontology - is it?

Is there another document with a more precise description of
syntax-case macros, that may be a useful reference for the future?

By the way (this might need a new list topic) what is your opinion of SRFI 72?

On Thu, Jun 18, 2009 at 6:36 PM, Abdulaziz Ghuloum<[email protected]> wrote:
>
> On Jun 14, 2009, at 10:46 PM, Abdulaziz Ghuloum wrote:
>
>>
>> On Jun 14, 2009, at 6:01 PM, Abdulaziz Ghuloum wrote:
>>
>>> (define-syntax when-bound
>>>  (lambda (x)
>>>    (syntax-case x ()
>>>      [(ctxt (id) e* ...)
>>>       (let ([t (car (generate-temporaries '(t)))])
>>>         (if (free-identifier=? #'id
>>>                (datum->syntax t (syntax->datum #'id)))
>>>             #'(begin)
>>>             #'(begin e* ...)))])))
>>
>> BTW, this is not a 100% correct definition of when-bound, but
>> it should suffice for given need.
>
> Clarifications:
>
> In R6RS, about datum->syntax, it says:
>
>  (datum->syntax template-id datum )        procedure
>  Template-id must be a template identifier and datum
>  should be a datum value.
>
> I have no idea what it means for an identifier to be a "template
> identifier", so, I don't know if (car (generate-temporaries '(t)))
> qualifies as one.  That might be a portability concern if some
> implementation has a different interpretation of this undefined
> term.
>
> Also in R6RS:
>
>  (generate-temporaries l)                 procedure
>  [...] Each temporary is guaranteed to be unique,
>  i.e., different from all other identifiers.
>
> Here, R6RS does not explicitly require that temporaries have
> empty environments associated with them, only that they are
> "different" from other identifiers (which I take to mean that
> they cannot be free-identifier=? or bound-identifier=? to any
> other identifier).  Ikarus, Larceny, and PLT happen to produce
> identifiers with an empty lexical environment, but this does
> not seem to be a guaranteed behavior according to R6RS as far
> as I can tell.
>
> Aziz,,,
>

Reply via email to