guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] local-eval, local-compile, and the-environment (v3)


From: David Kastrup
Subject: Re: [PATCH] local-eval, local-compile, and the-environment (v3)
Date: Sun, 15 Jan 2012 21:12:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Mark H Weaver <address@hidden> writes:

> David Kastrup <address@hidden> writes:
>
>>> You are suggesting that we wrap the expression within a (let () ...),
>>> for the dubious benefit of allowing you to wrap the local forms in
>>> (begin ...) instead of (let () ...).
>>
>> Are there even situations where you could put definitions after begin?
>> How are they different from the situation where you can't?
>>
>>> I don't see any compelling benefit to this.  On the other hand, I see
>>> less elegant semantics and potential confusion among users, who might
>>> reasonably expect the definitions in their (begin ...) to be added to
>>> the implicit `letrec', as would happen if the (begin ...) were put in
>>> place of (the-environment).
>>
>> begin can start with definitions, but not always?  But (let () ...) can?
>>
>> Scheme is weird.
>
> `begin' is indeed quite weird in Scheme.  Its meaning depends on the
> context where it is found:
>
> * In expression context, it is like `progn' in Lisp.  It evaluates the
>   expressions in order from left to right, and returns the value(s) of
>   the last expression.
>
> * At the top-level, or within an internal body where local definitions
>   are allowed (i.e. if every form above it in the internal body is a
>   definition), it is a _splicing_ operator: it acts as if the contents
>   of the begin were spliced into the surrounding context.  This is
>   mainly for the benefit of macros, so that they may expand into
>   multiple definitions.

Well, what if begin were able to splice definitions into the original
lexical context of the-environment?  I think it would be strange if a
continuation taken in that context would get to see new definitions.
And if a continuation there does not get to see it, it would be strange
if successive calls of local-eval on the same environment got to see it.

So there is not much of a sensible option except an implicit (let ()
...) wrapper for the sake of splicing begin, or bugging out for new
definitions.

In the light of local-eval evaluating a _form_ rather than a _body_
(stupid of me to forget), and seeing the weird semantics of begin, I
agree that an implicit (let () ...) wrapper for a single form does not
really appear to add significant gains.  It would be marginally
convenient and marginally confusing.

So one might as well forget about it.

-- 
David Kastrup




reply via email to

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