> Consider this:
> sage: E = (x+3)*sin(x)
> sage: E(5)
> 8*sin(5)
> sage: E.subs(x=5)
> 8*sin(5)
>
> So E(5) is treated as a shorthand for E.subs(x=5).
>
> Now if we consider:
> sage: var('f x')
> (f, x)
> sage: f(x+3)
> x + 3
> sage: f.subs(f=x+3)
> x + 3
>
> it's the exact same thing.
>
> This causes trouble in other situations, as well; if you wanted
> multiplication, but you left off the '*' symbol:
> sage: x(x+1)
> x + 1
> sage: x.subs(x=x+1)
> x + 1

This would only be ambiguous for current Sage behavior if
ImplicitMultiplication=True, correct (if even there)?  Just checking;
perhaps there are other places this notation occurs I haven't seen,
and I would be very interested in that if it were the case.

>
> I've argued before that this shorthand should be removed because it's
> too confusing, but I haven't managed to convince enough people, so
> it's still there.  (The shorthand isn't there in the new, Pynac-based
> symbolics, so when we switch over to that system, this particular
> source of confusion will be gone.)

Hmm, I didn't know that.  So I tried it.

sage: f=x^2
sage: f(2)
4
sage: y=var('y',ns=1)
sage: g=y^2
sage: g(2)
<long error message telling me subs doesn't work here>

So does that mean that this particular shorthand for subs will never
reappear in Pynac, or just that as currently implemented it doesn't
use it?  It doesn't look all that difficult to do a check for
'unambiguity' ala Robert's comment:
sage: g.variables()==1
True
and then do something like
sage: temp=g.variables()[0]
sage: g.subs(temp=2)
4
in the symbolic/expression.pyx code.  Or am I missing something?  I
understand the point about multi-variable situations.

Anyway, as several have commented, this discussion has taken place
many times before, but having to use
sage: f(x)=x^2
instead of
sage: f=x^2
many times for single-variable symbolic expressions could be very
annoying in the long run, IMHO.  Let's not be stultified by trying to
solve computer problems when this is mathematical software; the
distinction between symbolic and callable-symbolic seems different to
me than e.g. formal power series versus actually convergent ones.
FWIW.

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

Reply via email to