On 12/26/2010 5:49 PM, Daniel Lichtblau wrote:
>
> ----- Original Message -----
>> From: "Richard Fateman"<fateman at cs.berkeley.edu>
>> To: mathgroup at smc.vnet.net
>> Sent: Friday, December 24, 2010 3:11:55 AM
>> Subject: [mg114958] Re: Mathematica daily WTF
>> On 12/23/2010 12:55 AM, kj wrote:
>>> In<ies9t9$aa9$1 at smc.vnet.net> Andrzej Kozlowski<akoz at mimuw.edu.pl>
>>> writes:
>>>
>>>> Actually, there is nothing puzzling about this at all.
>> You can only judge if something puzzles you, yourself.
>>
>> The general topic of naming and binding has been seriously mishandled
>> over the years by WRI. Hence the original Block was found lacking and
>> so Module was introduced. Module does not really do lexical scope
>> since
>> the names it makes up are accessible global symbols like foo$123.
> I see no indication from this of any mishandling. Block is primarily a dynamic scoping mechanism. Module emulates lexical scoping.
No? Feature X exists. Feature Y, which looks to the naive user as identical, is introduced.
(For people who don't understand dynamic or lexical binding...) Why? Adding a feature? Fixing a bug?
You say feature, I say the orginal design was found lacking.
And as we've seen, the failure to uniformly change the access to the global bindings of
Attributes and documentation is puzzling and/or underdocumented. And Hold/Release, don't ask.
> It is an imperfect emulation.
Yes
> That does not make it bad,
Well, I believe it didn't have to be that way.
> and indeed there are situations in which symbol leakage is useful (some examples of such have appeared in this forum).
I suspect also there may be cases where the symbol leakage results in
filling up memory, but I have
not explored this, personally. I believe symbol leakage can be
"emulated" if needed.
> I am fairly certain it is useful to have both types of scoping construct, so if anything the adding of Module was a really good idea.
Common Lisp has both mechanisms. Dynamic binding (like Block) is usually
quite rare in modern programs.
There are more binding mysteries, however. The left and right hand
sides of patterns, and the effect of Hold and friends.
Now I myself don't find this terribly confusing, and I am sure Andrzej
feels the same way.
x=aha
s = Module[{x}, g[x_,x]:>h[x]]
g[a,x]/.s
s = Block[{x}, g[x_,x]:>h[x]]
g[a,x]/.s
s = Module[{x}, g[x_,x]->h[x]]
g[a,x]/.s
s = Block[{x}, g[x_,x]->h[x]]
g[a,x]/.s
but some people might puzzle over the answers to g[a,x]/.s which are,
in sequence,
g[a,aha], h[a], g[a,aha], h[aha].
There may also be questions about how these differ
ReleaseHold [ Module[{x=x},Hold[x]]]
ReleaseHold [ Module[{x},Hold[x]]]
Module[{x=Unevaluated[x]}, Evaluate[x]]
not to mention HoldPattern and Verbatim.