Python vs. Io

Daniel Ehrenberg LittleDanEhren at yahoo.com
Sun Feb 1 21:56:40 EST 2004


> Another thought about that:  from the Python version, barks is
> evidently a function.  Even if were a data attribute, I think
> in classical usage it would be a "message", and given that a
> class instance can implement its own attribute lookup, we may
> as well say that data attributes are simply functions with no
> extra parameters.
> 
> So, how odd that anyone would think of putting the function
> AFTER the object.  Did this come from Forth or something?
> 
> In the above example it looks somewhat natural, but only
> because of a declarative flavor that is hardly the rule in
> OO programming.  Take wl.append(w), for example - we're so
> used to this notation there's no point in asking if it would
> make more sense written append.wl(w), but if we're looking
> at a language that has taken a more lispish notation, I'd
> suggest "append wl w" is far more consonant with normal
> (not Forth) programming language notation.
> 
> That leads to an interesting generalization.  Take a common
> thorn out of Python's hide: "join sep wl".  Is "join" a member
> function of sep, or a plain function?  Well, who cares?  If
> sep has a join function, it should apply in this case, but if
> not, there's a generic.  In essence, all functions with 1 or
> more arguments are "member" functions - either of the class
> in which they're declared, or of the generic object class at
> the top of the object hierarchy.
> 
> 	Donn Cave, donn at drizzle.com

In your advocacy of Lisp over Forth (something completely unrelated to
this thread and newsgroup), you miss the major selling point of object
orientation: encapsulation. If you had barks(Dog) instead of
Dog.bark() (I'm using Python not Io syntax for now), bark() is
accessible to everyone, not just Dogs. So I could write bark(Cat),
which shouldn't work. Also, some of your examples of things that are
ambiguous really aren't ambiguous because neither Python nor any other
language uses spaces both in the way they are used in Lisp and the way
they are used in Smalltalk.

Daniel Ehrenberg



More information about the Python-list mailing list