chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] extending define-values


From: Alex Shinn
Subject: Re: [Chicken-hackers] extending define-values
Date: Tue, 9 Apr 2013 06:33:48 +0900

On Tue, Apr 9, 2013 at 5:40 AM, Felix <address@hidden> wrote:
>> >> > If you wanted to go this route you could just grab the portable
>> >> > reference implementation of define-values, no need to touch
>> >> > internals.
>> >>
>> >> This wouldn't work for internal definitions, I think. Is "define-values"
>> >> allowed for local definitions in R7RS?
>> >>
>> >
>> > It's just syntax which expands into internal definitions.
>> > The only way it could not work is with an implementation
>> > which looks for internal defines statically before expanding
>> > the lambda body.

"define-values" can not simply expand into a bunch of "defines".  To
allow it to be intermixed with "define" in internal definitions, it
needs be special cased, due to the use of "call-with-values" (which
would "break" the sequence of definitions and treat all following
forms of the body as non-definitions). Or not? At least I can't
think of any other solution than treating it explicitly.

It just expands into a sequence of defines, with
all but the last initialized to #f, and the last uses
call-with-values and set! to fill in the others.

[And no, call/cc does not expose or break this.]

 BTW, where can I find the portable reference implementation you
mentioned?

Both in the derived syntax section of the draft and
in chibi (which passes all the define-values cases of the
standard test suite).

>>
>> What about detection for redefinitions of defining forms
>> ("define-values" in this case)? Wouldn't that need special handling?
>>
>
> That's an error according to the standard, section 5.4:
>
>   "... it is an error for a definition to define an identifier whose
> binding has to
>    be known in order to determine the meaning of the definition itself..."
>
> with the standard R5RS error examples including
>
>   (define define 3)
>

Yes, I've heard of that before. What about

  (define-values define-values 3)

?

It's the same restriction.  This is an essential restriction
to the language, otherwise the same argument applies to
any syntax that expands into a define.  At that point, why
even bother having macros if everything has to be hard-coded
into the core?

-- 
Alex


reply via email to

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