pearu / sympycore

Automatically exported from code.google.com/p/sympycore
Other
11 stars 1 forks source link

evaluate keyword arg #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
All common operator-style functions should have an 'evaluate=True' default
keyword argument that can be set to False to suppress evaluation.

Examples of usage:

factorial(1000000, evaluate=False)
integrate((1+x)**10000, x, evaluate=False)
Mul(2, (x+y), evaluate=False) -> 2*(x+y)

This both avoids the need for separate verb/noun forms of certain
operations (which is confusing IMO) and gives a natural way to bypass
automatic transformations like those performed by __mul__.

Original issue reported on code.google.com by fredrik....@gmail.com on 22 Feb 2008 at 12:09

GoogleCodeExporter commented 9 years ago
Agreed.

An open question is whether `evaluate` should be applied also
to converting arguments. For example,

Mul(2, 3, evaluate=False) -> `2*3` or `6`?
Mul('2', '3', evaluate=False) -> `2*3` or `6`?
Mul('2+1', '3', evaluate=False) -> `3*3` or `9` or `(2+1)*3`?

If `evaluate` will be applied to converting arguments
then the unevaluated expression support would be easier
to implement using context managers.

Original comment by pearu.peterson on 8 Apr 2008 at 9:51