While looking at #15786 with an eye to understanding the architecture of 
sage, I noticed the following comment before the __call__ method of 
Function_ceil and Function_floor.

#FIXME: this should be moved to _eval_

After some rummaging about I see that the problem is that the function 
looks something like

def __call__(self, x):
    try a bunch of stuff
    else:
         return BuiltinFunction.__call__(self, SR(x_original))

the intention being, if we cannot find a numerical result, just leave it as 
a symbolic result.  This works when we overload the __call__ interface 
because the BuiltinFunction.__call__ will not reach our code again.

Unfortunately, if we move all of the code from Function_ceil.__call__ to 
Function_ceil._eval_ then the call to BuiltinFunction.__call__ will then 
call Function_ceil._eval_ and we are on the way to infinite recursion.  We 
cannot call BuiltinFunction._eval_, because BuiltinFunction does not 
implement _eval_.

Is there some way to avoid this recursion?  What is the problem with 
overloading __call__?

On a not entirely unrelated note, is the expected interface for classes 
that inherit from BuiltinFunction documented somewhere.  The ones I know 
about are listed in the code for BuiltinFunction._register_function, but 
don't seem to be documented.  For example, I believe that _evalf is 
supposed to be the numerical evaluation function, but do not have a clear 
understanding of what types it is expected to return, what exceptions it is 
expected to raise, etc.  



-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" 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-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to