At 07:04 PM 12/3/03 +0200, Christos Georgiou wrote: >A minor correction: the Voodoo approach handles fine method calls by >defining a __call__ method in the Voodoo class; __call__ is needed for the resulting object to be callable. >it can't handle >*function* calls in an elegant way: > >lambda x: x.startswith("text") >This works fine as: >Voodoo().startswith("text") Voodoo().startswith("text") is equivalent to (lambda x: x.startswith)("text"), which is not the same thing. >lambda x: math.sin(x) >This needs gross syntax, the following does not work: >math.sin(Voodoo()) That too, but also method calls. Basically, once you get past really simple expressions, the whole thing collapses under its own weight. Ironically, it would be easy to do this with generic functions, since one would simply define a methods for the case 'math.sin(Voodoo)' that returns lambda x: math.sin(x). (Hm. This gives me an entirely unrelated idea about how to unify object methods and generic functions in Python using "curried generics". Interesting. And the Voodoo() aka 'arg()' concept could be applied to predicate dispatching as well.)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4