Python Macros

Alex Martelli aleaxit at yahoo.com
Wed Oct 6 04:42:09 EDT 2004


gabriele renzi <rff_rff at remove-yahoo.it> wrote:

> > Why do you feel you need to extend the language for this? Why not (for
> > example) overload <<, >> and similar operators? __lshift__, __rshift__ etc.
> 
> ah, so the OP is asking about Higher Order Messages a-la F-Script? (or
> hyper ops a-la perl6)
> 
> I don't think this can be done in pure python. You can do half of it, say:
> collection >> stuff # map the stuff over the collection
> or
> collection >> operator << othercollection
> 
> but you cant do
> 
> stuff operator << collection

Assuming all of these identifiers are just such, you can't use the
latter syntax sugar (nor could you use the shorter 'stuff oper' sugar
either even without the << tail), but just tweak the syntax sugar
slightly (e.g. put a dot between the identifiers, which syntactically
you can't just juxtapose -- or, insert some operator there) and I'd
expect you can build whatever weird semantics you intend to (whether it
would make any _SENSE_ to go to such contortions is another issue, of
course -- not knowing what semantics you expect to associate to this not
exactly self-documenting syntax, I can't really guess).


Alex



More information about the Python-list mailing list