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

Re: To quote or not to quote, that is the question

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



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
<dvanhorn@xxxxxxxxxxxxxxx> wrote:
> Alexey Radul wrote:
>>
>> On Fri, Sep 18, 2009 at 4:48 PM, David Van Horn
>> <dvanhorn@xxxxxxxxxxxxxxx> 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
>
>
>