python hack of the day -- "listable" functions
William Tanksley
wtanksle at dolphin.openprojects.net
Sat May 15 15:54:38 EDT 1999
On Sat, 15 May 1999 18:01:10 GMT, Jim Meier wrote:
>William Tanksley wrote:
>> Now, consider this.
>> x = o.verb(a,b,c)
>> You've created a language feature where the action of the verb depends not
>> on the single object it's attached to, but on EACH of the parts of speech
>> in its parameter list.
>> After that change, Python wouldn't be object oriented. It'd be grammar
>> oriented.
>> Let that one sink in for a while.
>I think grammar-oriented languages are a very, very interesting idea. I saw a
>posting somewhere(freshmeat.net?) about a language whose modules were allowed
>to define and maybe redefine syntax. struck me as neat, but to wrap it together
>and call it "grammar".. could we "conjugate" verbs for different effect?? wow..
Conjugation isn't an aspect of grammar in general. It's only part of
certain languages. Lojban isn't conjugated at all (but then Lojban is an
artificial language).
>> Ouch. Has anyone done work on how to do that? It's polymorphism, but
>> with the action depending on every parameter rather than just one.
>How is it different from normal polymorhpism?
It's different because normal polymorphism dispatches to only one object.
This would be dispatching to several.
>The language (if it cares) would
>dispatch to the member function whose signature matched the parameters. This is
>normal in many OO languages (C++ being the first to come to mind)
This is called "overloading", not polymorphism. As a matter of fact,
overloading makes OO _very_ difficult, and makes it easy to make bad
mistakes which the compiler and runtime can't catch.
Overloading looks like multiple dispatch but isn't, just like static
binding looks like OO but isn't.
>-Jim.
--
-William "Billy" Tanksley
"But you shall not escape my iambics."
-- Gaius Valerius Catullus
More information about the Python-list
mailing list