Why we will use obj$func() often

Mark Hahn mark at prothon.org
Fri Apr 23 19:36:15 EDT 2004


"Donn Cave" <donn at u.washington.edu> wrote ...

> What you're doing there looks to me a bit like Objective
> CAML's ref type.  "a = ref 0" is a mutable container for an
> immutable integer.  It's just syntactic sugar for a mutable
> record;  the sugar is the assignment a := 1, and then there's
> some special dereference notation -- a := !a + 1, something
> like that, I forget.

I'm not doing anything nearly that complex.  &var just gives access to the
outer closure scope and directly accesses var in that scope, just like
accessing a global variable.  It isn't just syntax sugar for var[0] because
it has none of the list overhead associated with the var[0] kludge.  & 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.





More information about the Python-list mailing list