[Top][All Lists]

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

Re: Feature request: Expose `ellipsis?' from

From: Marc Nieper-Wißkirchen
Subject: Re: Feature request: Expose `ellipsis?' from
Date: Wed, 14 Nov 2018 21:27:17 +0100

Hi Mark,

thank you very much for replying so quickly.

Am Mi., 14. Nov. 2018 um 20:11 Uhr schrieb Mark H Weaver <address@hidden>:
> The `ellipsis?' procedure in does exactly this, but it
> isn't available to user code. Re-implementing it is not possible
> without accessing internal details like the special identifier #{
> $sc-ellipsis }# and without resorting to hacks.

Surprisingly, it actually _is_ possible to do it portably in any
R[567]RS Scheme.  See 'match-check-ellipsis' near the end of

This is why I wrote "without resorting to hacks". :-) Like `ellipsis?', `bound-identifier=?' and `free-identifier=?' can also be portably implemented in R5RS, and I had to use all these tricks to provide a portable implementation of SRFI-148. But it is nicer to have `bound-identifier?' and `free-identifier?' as procedures that can be called by macro transformers easily. And so I think of `ellipsis?'.
> Thus, I would like to ask to add `ellipsis?' to the list of procedures
> exported by Guile (like `identifier?` or `bound-identifier=?` already
> are).

I'll need to think about how this could be exposed in the API.  It's not
as simple as exporting that procedure.  The 'ellipsis?' procedure is not
able to answer the question by looking only at the syntax object; it
also needs the macro-expansion environment 'r', which you do not have.
'identifier?' and 'bound-identifier=?' only need the syntax objects.

I think I understand (please correct me if I am wrong): If we want to check whether `e' is the current ellipsis, we cannot simply look up the binding of `(datum->syntax e '$sc-expand)' because the wrap of `e' may be different than the wrap of the, say, `syntax-case' or `syntax' form in which `e' appears. 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'.

-- Marc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]