#10747: symbolic functions can be defined with a constant argument
----------------------------------------------------------+-----------------
    Reporter:  pang                                       |         Owner:  
burcin      
        Type:  defect                                     |        Status:  
needs_review
    Priority:  minor                                      |     Milestone:  
sage-4.7.1  
   Component:  misc                                       |    Resolution:      
        
    Keywords:  symbolic function, assignment, sd31        |   Work_issues:      
        
    Upstream:  N/A                                        |      Reviewer:      
        
      Author:  Burcin Erocal, Zafeirakis Zafeirakopoulos  |        Merged:      
        
Dependencies:                                             |  
----------------------------------------------------------+-----------------
Changes (by newvalueoldvalue):

  * status:  new => needs_review
  * author:  => Burcin Erocal, Zafeirakis Zafeirakopoulos
 * cc: boothby (added)
  * component:  symbolics => misc
  * keywords:  symbolic function, assignment => symbolic function,
               assignment, sd31


Old description:

> The expression
> {{{
> h(6)=8
> }}}
> currently defines a symbolic function ``h`` with constant value 8. This
> makes no sense, but begginers make this mistake, for example if h is an
> array and they use () instead of []. It doesn't hurt to throw an error at
> all expressions
> {{{
> h(something) = ...
> }}}
> whenever something is not a symbolic variable.

New description:

 The expression
 {{{
 h(6)=8
 }}}
 currently defines a symbolic function ``h`` with constant value 8. This
 makes no sense, but begginers make this mistake, for example if h is an
 array and they use () instead of []. It doesn't hurt to throw an error at
 all expressions
 {{{
 h(something) = ...
 }}}
 whenever something is not a symbolic variable.

 Apply [attachment:trac_10747-preparse_calculus.2.patch],
 [attachment:trac_10747-preparser-docstrings-symbolic-vars.patch]

--

Comment:

 It seems the real problem is in the preparser. Normally, when `f(1)=2` is
 preparsed on the command line, it becomes `f(Integer(1))=Integer(2)`. This
 is not valid python so we get an error anyway. In the notebook, the
 constants are extracted and assigned to variables named `_sage_const_*`.
 Then the `preparse_calculus()` function receives
 `f(_sage_const_2)=sage_const_3` as input, which is a valid construction.

 [attachment:trac_10747-preparse_calculus.2.patch] changes
 `preparse_calculus()` to raise an error if the argument name starts with
 `sage.misc.preparser.numeric_literal_prefix`.

 [attachment:trac_10747-preparser-docstrings-symbolic-vars.patch] adds
 doctest for the errors on the command line and the notebook.

 It would be better if someone more familiar with the preparser reviewed my
 patch.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10747#comment:6>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to