Deprecate self

Douglas Alan nessus at mit.edu
Wed Apr 18 04:24:07 EDT 2001


whisper at oz.net (Dave LeBlanc) writes:

> 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.

|>oug



More information about the Python-list mailing list