Title: RE: [Python-3000] AST access (WAS: Adaptation vs. Generic Functions)

Talin wrote:
> What remains is a consise way to specify bound vs.
> unbound variables I would prefer not to have to
> restrict people to using a limited set of pre-declared
> undefined variables, i.e. X, Y, Z, etc.; plus I
> would want to be able to associate additional
> constraints with those unbound variables.

In Dejavu I did that with a separate "kwargs" attribute on the _expression_ object. You can set the kwargs attribute and it will be used when the _expression_ is evaluated:

>>> e = logic._expression_(lambda a, b, **kw: a + b + kw['c'])
>>> e.kwargs.update({'c': 16})
>>> e.evaluate(1, 8)
25

The "evaluate" method is a synonym for __call__ as well, and you can override previously-bound kwargs during evaluation:

>>> e(1, 8, c=256)
265


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to