Why we will use obj$func() often
Donn Cave
donn at drizzle.com
Sat Apr 24 01:04:38 EDT 2004
Quoth "Mark Hahn" <mark at prothon.org>:
...
| ... & just
| tells the compiler where to find the variable, just like capitalized
| variables in Prothon say to find them in the global space and .var says to
| find var in self.
...
| The whole point is to make things simpler, more readable, and more
| efficient, but when people see the & symbol they somehow automatically think
| it's complex. Maybe my mind doesn't work like everyone else's.
It may be one the language inventor's perils - hard to communicate
with people in a language you just invented for the purpose!
To me, if you want simple - this counter closure thing is done
better with an object. It's weird, unnatural and sounds like
an implementation headache to support persistence in a function
local variable namespace. I don't know if Python does that
already, but that wouldn't make it any better. When I want
a thing with persistent data, I'm thinking of an object. One
must keep things simple.
I think if I were writing a language from scratch, one that's
vaguely similar to Python but not especially, I might seriously
consider what I believe we call lexical scoping, and a declaration -
not assigning a type, but an initial value, like "let x = 0".
Namespaces like Python's would be for objects - modules, classes,
class instances, whatever - not functions - and would be purely
explicit, not implicit like a scope (I think that would most
conspicuously require some alternative for "def" statements,
for example.)
Donn Cave, donn at drizzle.com
More information about the Python-list
mailing list