[Prev][Next][Index][Thread]
Re: Closures
Does anyone know if Ruby implement proper lexical closures in this sense?
--Rick T
> I've noticed that the designers (and probably users) of many languages
> don't seem to care about having closures with the "shared binding"
> assignment semantics and hence are willing to put up with assignment
> behaving differently when it "crosses" the lexical boundary of
> the inner procedure, function, or whatever. They seem to be quite
> happy with some kind of "approximate closure" that has some other
> assignment semantics and is typically easier to implement.
>
> (Another example is Pop-11 and related languages, where they use
> "frozen formals", a kind of currying, again without shared bindings.)
>
> This is in contrast with Lisp. In the various kinds of Lisp, there
> were a number of experiments different kinds of "approximate
> closures", but there was often an effort to get the "shared binding"
> semantics even when other things were rather messy. (For example, you
> might have to explicitly list the variables to close over and declare
> them all to be dynamically scoped.) No one approach achieved general
> acceptance until proper lexical closures came along.
>
> My guess is that the Dylan designers (you see, I did eventually get
> around to Dylan) never seriously considered anything else.
>
> The interesting question is why: why have Dylan and modern Lisps
> gone this way when virtually no one else has? Why were Lisp and Dylan
> not satisfied with some kind of "approximate closure" when so many
> others were? Java came close but didn't take the final step of supporting
> assignment. In functional languages, the issue doesn't arise (no
> assignment); and in ML they avoid it by using explicit ref objects.
>
> (By the way, does Perl have lexical scoping?)
>
> -- Jeff
>
Follow-Ups:
- Re: Closures
- From: mjones@ipx.frottage.org (Mark Hulme-Jones)
References: