'isa' keyword

Steve Holden steve at holdenweb.com
Thu Sep 1 21:39:14 EDT 2005


phil hunt wrote:
> On 1 Sep 2005 00:52:54 -0700, talin at acm dot org <viridia at gmail.com> wrote:
> 
>>The "isa" operator would of course be overloadable, perhaps by an
>>accessor functions called __isa__, which works similarly to
>>__contains__. The potential uses for this are not limited to
>>isinstance() sugar, however. For example:
>>
>>   if image isa gif:
>>   elif image isa jpeg:
>>   elif image isa png:
> 
> 
> What's wrong with:
> 
>     if image.isa(gif):
>     elif image.isa(jpeg):
>     elif image.isa(png):
> 
> In short, I see no need to add further complexity to Python's 
> grammar.
> 
> It could be argued of course, that an OOPL should allow methods to 
> be sent with a grammar:
> 
>    receiver selector argument
> 
> (which is almost what Smalltalk does), but you're not arguing for 
> that (and I'm not sure it would work with the rest of python's 
> grammar).
> 
Even if it did it might mangle operator precedence in the same way 
SmallTalk did, which I always felt was one of the least attractive 
features" of the language.

I don't think a change to a message-passing paradigm would necessarily 
benefit Python at this stage. Some people are still under the 
misapprehension that message-passing is a fundamental of object-oriented 
programming because of Smalltalk, but they are wrong.

The addition of an "isa" operator would be an unnecessary addition of 
pure syntactic sugar.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/




More information about the Python-list mailing list