Deprecate self

Dave LeBlanc whisper at oz.net
Wed Apr 18 12:40:48 EDT 2001


Smalltalk never requres the declaration of self as an arguement to a
method. self is only used to identify the target (variable or method
invocation) as being local to the caller (i.e. in it's own class
scope). It's been awhile, so I don't recall if it's mandatory in that
context or not.

I was going to mention super, but given the multiple inheritance
nature of Python, it wouldn't work.

Dave LeBlanc

On Wed, 18 Apr 2001 13:54:55 GMT, grante at visi.com (Grant Edwards)
wrote:

>In article <lc8zkyehug.fsf at gaffa.mit.edu>, Douglas Alan wrote:
>
>>> Since self is used for every method of every class, isn't it a bit
>>> redundant?
>>
>>Many people find it less confusing to read code that is written this
>>way.  Otherwise, when you see a variable, you have more choices as to
>>where the variable might be defined: the local scope, the global
>>scope, the class scope, etc.
>>
>>> I don't know of another OO language that makes you manually carry
>>> around the "this"/"self" pointer/reference...
>>
>>Languages with multimethods routinely do, because multimethods are
>>typically not class-centric.  I.e., a generic function in a language
>>with multimethods dispatches on all the arguments, not just on one of
>>them, so no particular argument is given special treatment.
>>
>>For class-centric OO languages, I agree with you -- I don't personally
>>know of any others that require explicit use of self.
>
>Smalltalk and Modula-3 both do, IIRC.
>
>-- 
>Grant Edwards                   grante             Yow!  We just joined the
>                                  at               civil hair patrol!
>                               visi.com            




More information about the Python-list mailing list