The whitespaceless frontend

Stelios Xanthakis sxanth at cs.teiath.gr
Tue Apr 25 02:38:19 EDT 2006


Hi,

bearophileHUGS at lycos.com wrote:

> but maybe instead of the global.name something to refer to the upper
> namespace (that can be the global one or the namespace of the function
> that contains this one) can be more general:
> upper.x = 1
> upper.upper.x = 1
> 

Well, people have been trying to come up with a way to solve the nested
scopes restrictions.  This may work, but in my opinion nested functions
are not so important and I wouldn't spend any time to improve them.
Usually you can do anything with classes (and "method" makes that 
easier). If we say that """closures were invented so that we will avoid
the extra typing in cases like

	def f (self):
		x = lambda self=self: return self.foo ()

and beyond that perhaps it is a sign that we should rethink our
design""" we can accept the limitations of python's closures.


> I think that making self a reserved word that can be used only for its
> usual purpose can be positive.
> 

I agree. EPL does not have shoot-self-in-the-foot protections yet,
but it will :)

> The $ and method statement seem interesting too, but the first is a
> little perlish (but Ruby has something similar, and people like it),
> and the method statement look a little redundant. I think the $ can be
> acceptable (Mostly to reduce typing), even if it doesn't look very
> nice.
>

'$' is perlish and rubyish (and I got it from ruby indeed).
It's the cost of a dynamic language :)
In static languages we know at compile-time whether a symbol is local,
instance or global. In dynamic languages where scopes are modified when
the program runs we have to type something. '$' being unused seems like
a good choice.

"method" is good not only because we avoid the extra typing in the
definition, but also because -after experiments- it seems that
restricting the use of $ in methods, will simplify some confusing
cases.  For example, what happens in:

     def foo (cls):
         def bar (self):
             return $x     # what's that? cls.x or self.x?

While now, when you see $ you know it refers to the instance of the
"method".  And nested methods in methods are very rare.

Bye,
Stelios

- sorry for the delayed reply. Unexpected easter vacation.



More information about the Python-list mailing list