#14231: warn when preparser redefines Python builtin function
-------------------------------------------------------+--------------------
       Reporter:  ddrake                               |         Owner:  was    
 
           Type:  enhancement                          |        Status:  new    
 
       Priority:  major                                |     Milestone:  
sage-5.8
      Component:  user interface                       |    Resolution:         
 
       Keywords:  symbolic preparser builtin built-in  |   Work issues:         
 
Report Upstream:  N/A                                  |     Reviewers:         
 
        Authors:  Dan Drake                            |     Merged in:         
 
   Dependencies:                                       |      Stopgaps:         
 
-------------------------------------------------------+--------------------

Comment (by nbruin):

 How about the list:
 {{{
 __builtin__.__dict__.keys()
 }}}
 If the problem is detected you could insert a warning printing message
 into the preparsing result. Then the warning printing gets executed
 together with the symbol binding.

 The real problem here is that previously mistyping `len(t)==4` as
 `len(t)=4` resulted in invalid syntax, whereas now it results in an
 assignment. The same surprise happens when someone types
 {{{
 t = 0
 sin(t) = 0 # mistyping of sin(t) == 0
 }}}
 Do you want to guard against that as well? Then quickly the whole
 `f(t)=...` notation should lead to a warning (which I wouldn't mind
 because I think it's one of the places where the preprocessor is too
 intrusive)

 In fact, always printing:
 {{{
 sage: f(u,v)=u+v
 Defining symbolic function f and symbolic variables u,v
 }}}
 might not be so bad. We're defining new syntax. We can define new
 semantics for that syntax, right?
 We could have that result by ensuring that
 {{{
 sage: preparse('f(u,v)=u+v')
 '__tmp__=var("u,v"); f = symbolic_expression(u+v).function(u,v); print
 "Defining f and u,v"'
 }}}
 or whatever (terse) message would be reasonable.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14231#comment:3>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to