|
[Date Index]
[Thread Index]
[Author Index]
Re: looping
David Bailey wrote:
...
>
> To describe the Module mechanism as 'flawed' because you can't use it in
> this way, seems totally unreasonable - akin to describing real
> arithmetic as 'flawed' because it can't represent Sqrt[-1]!
Except that other programming languages provide the same facility
(lexical scope) while not having the same problem. That is, there is
the ordinary way of implementing lexical scope, not the Mathematica way.
>
> One of the nice features of Module, is that the method of localising
> names is totally explicit - so that it is easy to work out what is going
> on is subtle cases.
Mathematica's implementation is, I think, based on someone's reading of
an explanation of lexical scope. Perhaps, "You can think of L.S. as a
kind of renaming". But without reading the next sentence, which might
be "but of course it is not implemented that way".
I agree with your statement -- that looking at the strange renaming it
is possible to explain some phenomena that you might find puzzling. But
so many things having to do with scope in Mathematica are, at some
level, potentially puzzling, that this is a drop in the bucket. E.g.
when do names get bound during pattern matching? What is the real value
of something which is evaluated any number of times until it has no
remaining names, so that x=x+1 assigned
to x, 255+Hold[1+x], etc.
And proper lexical scope implementation is not so hard, I think. Even
given Mathematica semantics.
RJF
Prev by Date:
Re: ListLinePlot Labels
Next by Date:
Re: Using variable name as string AND value ?
Previous by thread:
Re: looping
Next by thread:
Re: looping
|