Hi there,

> It would be nice if we could do something like:
> 
> sage: f(x,0)=e^x
> 
> sage: f(x,t)=x*t
> 
> 
> or
> 
> sage: f(0)=0
> sage: f(x)=sin(x)/x
> 
> Is there an elegant way to have multiple definitions like this in pynac, 
> or definitions with specific conditions on the arguments?
> 
> This is one thing that is really nice about Mathematica: since things 
> work by pattern-matching, you can define a function different ways based 
> on all sorts of conditions on the inputs.  Mathematica then uses the 
> most general definition it can when trying to evaluate the function.

Unfortunately, f(...) = ... seems to be forbidden by the very syntax of
python. This is at least the third place where I see someone requesting to
remove this limitation. I don't know how at all how python guys are open but I
(and I'm sure I'm not the only one) would very much like to have be able to
write for an object <obj> of class <class>
    obj(params) = value
which is dispatched to something
    class.__setcall__(obj, (params), value)
otherwise said there is a symmetry
    __getitem__  / __setitem__
    __getslice__ / __setslice__
    __getattr__  / __setattr__
I very much like to have a symmetry
    __call__ = __getcall__ / __setcall__

How popular in sage people such a syntax would be ? Is there any chance if
requesting it to python to be heard ?


Once this is allowed, then implementing patter matching should be rather
easy. 

Cheers,

Florent

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to