Perhaps I am just dumb

wooks wookiz at hotmail.com
Mon Feb 11 10:17:40 CET 2002


quinn at hurl.ugcs.caltech.edu (Quinn Dunkan) wrote in message news:<slrna6dqet.dm.quinn at hurl.ugcs.caltech.edu>...
> 
> Polymorphism has traditionally been a big deal for static languages, because
> their compile time typechecking machinery needs to be powerful enough to
> generate polymorphic signatures.  Dynamic languages don't have compile time
> typechecking machinery, so it's not an issue.
> 
> For that matter, '+' works on both floats and ints in C, so it's polymorphic
> there too.  But if you wanted to *write* a function like '+' in C, it would
> want you to declare the types of the arguments, at which point you'd be stuck
> between saying "add() takes two ints" and "add() takes two floats" (in the C
> case, ints have built in magic that let them automatically turn into floats,
> but that's just for numbers (and I assume to make C's lack of polymorphism more
> bearable) and not all static languages do automatic conversion like that (e.g.
> in haskell "let {x=1::Int; y=2.0} in x+y" is an error)) so you can see why
> static languages make a ruckus about supporting (or not) polymorphism, while
> dynamic programmers might not even know what it is, but use it all the time
> anyway.

If I am getting you right the rest of the post translates what you
said in the first sentence.

Further if I get magic methods right, they are special functions which
if present enable the object to apply a unique interpretation of a
python operator.
So + has standard behaviour but will  adopt whatever is specified in
the __add__ function if one is present for the class.

Yes?



More information about the Python-list mailing list