loose methods: Smalltalk asPython
Steve Holden
steve at holdenweb.com
Fri Jan 26 10:53:25 EST 2007
Carl Banks wrote:
> Jan Theodore Galkowski wrote:
>>> We've not had
>>> an excellent dynamic OO language since Smalltalk, IMO.
>
> I would say that "excellence" in object oriented programming is not a
> strong design goal of Python. Python tries to support OOP well, but
> not to enhance OOP to the detriment of other, more important goals.
>
> [snip]
>>> Guido was opposed to modifying builtin types before Java existed. It's
>>> similar to his opposition to dynamic syntax.
>> Opposition or not, the language definition is there. Surely Smalltalk's
>> OO style can be respected. Smalltalkers have been doing OO in a dynamic
>> context longer than many. There are things to learn there.
>
> Well, that Smalltalk and Ruby do this at least suggests that it won't
> be the end of the world as we know it if it were to happen in Python.
> Personally, I'm with Guido here. Allowing this might make Python's OOP
> more "excellent", but it would be to the detriment of other, more
> important goals, like minimizing surprise.
>
>> There are two things here that need to be kept straight, I think.
>>
>> One is the primacy of builtin types.
>>
>> The other is placing those builtins at the top of their own object
>> hierarchy. Is "int", properly speaking, a descendent of "object"? No,
>> it's the root of its own tree.
>
> Are you saying that it shouldn't be a descendant of "object", or that
> it isn't? "int" is certainly a subclass of "object" in Python (as are
> all objects).
>
>> Smalltalk has "int" as well, as a
>> *subclass* of Number. It's primitive.
>
> Number is primitive? I thought all types in Smalltalk had a common
> base type.
>
> Anyways, Python 3000 is exploring the idea of an abstract hierarchy
> that has classes (interfaces?) like Number and Sequence. In fact, I
> even saw some talk about somehow being able to retrofit classes to
> support one of these interfaces/ABCs, though it was pretty conjectural.
>
>> In any case, as respectful of Mr/Dr van Rossum as I am, simply because
>> so-and-so says something is bad and therefore it must be true is a
>> fallacious response.
>
> The same could be said of Smalltalk, i.e., because Smalltalk does it
> therefore it is good is just as fallacious.
>
> Regardless, whatever Guido pronounces is what happens. If he's
> adamantly against something, it's pretty much an academic discussion.
>
Just to be perverse, there was an example recently where a developer
asked (on python-dev) about the best way to trap and note the creation
of all objects.
With a proper hierarchy, in which everything calls its parent's
constructor all the way up to object, in theory (and ignoring old-style
classes) it would be possible to simply modify the behaviour of object.
Unfortunately this is a no-no because object's behaviour is hard-wired
into the CPython interpreter.
The general feeling on python-dev seems to be that this is a step too
far, and that the confusion engendered by this kind of patching would
not be worth the benefits gained. Certainly it appears to this reader
that such a feature woudl be more abused than used.
The principle of least surprise thus reigns for now.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note: http://holdenweb.blogspot.com
More information about the Python-list
mailing list