#17547: BuiltinFunction overriding GiNaC function is allowed
-----------------------------+------------------------
       Reporter:  rws        |        Owner:
           Type:  defect     |       Status:  new
       Priority:  major      |    Milestone:  sage-6.5
      Component:  symbolics  |   Resolution:
       Keywords:             |    Merged in:
        Authors:             |    Reviewers:
Report Upstream:  N/A        |  Work issues:
         Branch:             |       Commit:
   Dependencies:             |     Stopgaps:
-----------------------------+------------------------

Old description:

> {{{
> 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
> }}}
> The attempt at creation should give an error (plus respective
> documentation warnings).
>
> Alternatively, search first for user-defined function names, then GiNaC
> core, to allow overriding.

New description:

 {{{
 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 e.g. `p2` `AFunction.eval` gets called, but not with name
 equal to a function provided with GiNaC. Compare the above with
 {{{
 ...
 sage: p2 = AFunction('p2', 2)
 sage: p2(x)
 x^2
 }}}
 The attempt at creation should give an error (plus respective
 documentation warnings).

 Alternatively, search first for user-defined function names, then GiNaC
 core, to allow overriding.

--

Comment (by rws):

 If the name is e.g. `p2` `AFunction.eval` gets called, but not with name
 equal to a function provided with GiNaC. Compare the above with
 {{{
 ...
 sage: p2 = AFunction('p2', 2)
 sage: p2(x)
 x^2
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/17547#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to