Bill Manaris
Posts: 4
Nickname: manaris
Registered: Nov, 2007
|
|
Re: A Response to Bruce Eckel
|
Posted: Mar 9, 2009 7:23 PM
|
|
> I completely agree with Bill Manaris and Bruce Eckel on > this. The explicit self is a violation of consistency and > clarity in the python language.
I think I finally have the answer... on how it is technically (and easily) feasible to get rid of 'self'. It took a couple of years, but here it is:
As George Sakkis said,
> obj.meth(*args, **kwds) > > is typically equivalent to > > obj.__class__.meth(obj, *args, **kwds)
So, instead of having the reader/parser do the above transformation, when calling a member function (as opposed to a free function):
1) Add a 'parent' ('owner'?) attribute within function objects.
2) When defining a free function, the evaluator sets the 'parent' attribute to 'None'.
3) When instantiating an object, the evaluator sets every 'parent' attribute of the object's member functions to the object itself.
4) When dynamically adding a free function to an object, e.g.,
>>> obj.method = freeMethod
the assignment operator updates the 'parent' attribute of 'freeMethod' to 'obj'. Both fields are readily available.
It sure looks simple, clean, and elegant. Goodbye explicit self!? Wouldn't that be something?
What am I missing?
Thanks,
Bill
|
|