Movatterモバイル変換


[0]ホーム

URL:


Deprecate self

Jeremy Hyltonjeremy at digicool.com
Wed Apr 18 10:49:12 EDT 2001


>>>>> "MvL" == Martin von Loewis <loewis at informatik.hu-berlin.de> writes:  MvL>whisper at oz.net (Dave LeBlanc) writes:  >> Since self is used for every method of every class, isn't it a  >> bit redundant? I don't know of another OO language that makes you  >> manually carry around the "this"/"self" pointer/reference...  MvL> In Smalltalk, invocations of operations on self always require  MvL> to provide the self argument. You don't have to declare it as a  MvL> method argument, though.Modula-3 was mentioned in another post.There is a reason other than simple clarity (I like using an explicitself) for this approach.  Python's rules for local variables wouldinterfere with attribute access.  Since Python eschews variabledeclarations, any assignment to a name inside a code block makes thatname a local variable.  By this rule alone, there would never by a wayto assign to an instance variable :-).  You'd need a mechanism likethe global statement to say "This name isn't a local."We had an opportunity to change the attribute access approach whennested scopes were introduced, but we went out of our way (well, sortof) to preserve the self.attr approach.Jeremy


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp