Python vs. Io

Donn Cave donn at drizzle.com
Sun Feb 1 13:18:58 EST 2004


|> Dog barks //Io
|> Dog.barks() #Python

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



More information about the Python-list mailing list