Re: To quote or not to quote, that is the question
Robby Findler 19 Sep 2009 13:27 UTC
I'm not sure about the conclusion, but you can (in a module), do that
kind of lifting in a PLT macro. Search for "lifts" in the docs.
Robby
On Sat, Sep 19, 2009 at 8:23 AM, David Van Horn
<xxxxxx@cs.brandeis.edu> wrote:
> Alexey Radul wrote:
>>
>> On Fri, Sep 18, 2009 at 4:48 PM, David Van Horn
>> <xxxxxx@cs.brandeis.edu> wrote:
>>>
>>> It is not possible to define a correct implementation of `quote' which
>>> produces random-access pairs as a library form
>>
>> This may be a stupid question: why not define random-access-quote to
>> use the standard quote and convert the result into a random-access
>> list? (This may involve recurring inside the elements of literal
>> vectors, but so be it).
>
> It's not stupid at all. The issue is that quoted a constant must always be
> `eq?' to itself. So for example:
>
> (define (f) '(x))
> (eq? (f) (f)) => #t
>
> Compared to:
>
> (define (f) (cons 'x '())
> (eq? (f) (f)) => #f
>
> If you look at the formal semantics of R6RS, you'll notice the metafunctions
> that lift quoted constants to the top so they are evaluated only once before
> they are expanded to constructors. You can't do that lifting with a macro.
> It's my understanding that with single-instantiation library semantics, you
> could achieve the right behavior by making a table, but that since
> implementations are not required to use single instantiation, this approach
> is not portable.
>
> Perhaps a macro wizard can prove me wrong. I would like that. But I'm
> pretty sure you just can't make a quote-like macro in a portable way, which
> is too bad.
>
> David
>
>
>