capturing (or not) mutable local variables
Neal Gafter
neal at gafter.com
Sun Nov 21 07:06:16 PST 2010
On Sun, Nov 21, 2010 at 1:21 AM, Alex Blewitt <alex.blewitt at gmail.com>wrote:
> On 21 Nov 2010, at 02:08, Neal Gafter <neal at gafter.com> wrote:
>
> > The point of my question is that mutable versus immutable has nothing to
> do
> > with variable lifetime. Pretending they have anything to do with each
> other
> > is just unnecessarily muddying the the discussion.
>
> Except that this assumes it is the same variable inside and outside the
> lambda. If it is semantically a different variable (with the lifetime of the
> closure) which has been assigned a copy of the value from the enclosing
> scope then mutability, or lack thereof, is key.
>
Is it semantically different? It appears in all ways to be a single
variable throughout its scope. The "lifetime of the variable" isn't part of
the semantics today, and if you distinguish one part of the variable's scope
from another by introducing this concept, you haven't added anything useful
to the description.
Do you mean to intend to allow the lambda to change the value of its copy?
If so, your description would have some meaning. If not, you're suggesting
a difference without a distinctions.
More information about the lambda-dev
mailing list