id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
17547 BuiltinFunction overriding GiNaC function rws "The attempt to create a symbolic function that prints with a name that is also used by a reserved GiNaC function results in unexpected behaviour when evaluating. The following should output `x^2` but completely bypasses `AFunction.eval`:
{{{
sage: from sage.symbolic.function import BuiltinFunction
sage: class AFunction(BuiltinFunction):
....: def __init__(self, name, exp=1):
....: self.exponent=exp
....: BuiltinFunction.__init__(self, name, nargs=1)
....: def _eval_(self, arg):
....: return arg**self.exponent
sage: p2 = AFunction('exp', 2)
sage: p2(x)
e^x
}}}
If the name is however e.g. `p2` then `AFunction.eval` gets called as expected. Compare the above with
{{{
...
sage: p2 = AFunction('p2', 2)
sage: p2(x)
x^2
}}}
This prevents creation of `BuiltinFunction`s as wrapper for functions reserved by Pynac with the same name like `factorial` (#17489), and forces every change into Pynac." defect new major sage-6.5 symbolics N/A