[Python-3000] Adaptation vs. Generic Functions
Phillip J. Eby
pje at telecommunity.com
Sat Apr 8 22:53:39 CEST 2006
At 08:29 AM 4/8/2006 -0700, Guido van Rossum wrote:
>Of course, there are applications for more general predicates (like a
>dungeons&dragons game dispatcher) but to me they all seem a bit
>specialized to me.
Sure - but it would certainly be nice if RuleDispatch could tie into the
Python-supplied mechanism and extend it to offer the predicates. They're
also quite useful for data-driven security rules:
http://peak.telecommunity.com/DevCenter/SecurityRules
and other pricing/business applications:
http://peak.telecommunity.com/DevCenter/CombiningResults
So it's not just games that benefit. :)
>I'm not sure if it's worth the complexity.
Fair enough - check out the use cases illustrated by the pages
above. Again, I just want to be able to make RuleDispatch look like an
extension of the base mchanism; I'm not trying to convince you to implement
all of RuleDispatch's features as part of Py3K. :) (Although that would
certainly be cool. ;) )
> Also, responding to stuff I
>snipped that you wrote about access to ASTs is incredibly far in the
>future; it's too close to macros or extensible syntax,
How is it extensible syntax if you have to use a *Python* AST? I also
don't think macros in the general sense can be practically implemented
using mere AST access of the type I described, since *each* function using
such "macros" would have to be decorated individually. IMO it would be a
PITA at best, especially since you couldn't change Python's syntax in any way.
To me an AST access feature would only be useful for changing the "VM" that
Python code runs on. For example, there is an object-relational mapper out
there (I think it's Robert Brewer's DejaVu system) that takes Python
generator expressions and converts them into SQL. Right now it does it by
bytecode hacking, because the only alternative is to parse a string.
More information about the Python-3000
mailing list