Changes between Initial Version and Version 2 of Ticket #17958


Ignore:
Timestamp:
03/16/15 09:48:11 (6 years ago)
Author:
rws
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17958

    • Property Cc nbruin added
    • Property Summary changed from implement declare_var to implement declare_var, deprecate (None)var
  • Ticket #17958 – Description

    initial v2  
    1 Functions returning a value should not have side effects, `var` does. In #17447, comment 23 Nils Bruin proposed to separate both usages of `var` by introducing `declare_var`: this should behave exactly like `var` without return value, i.e.
    2 {{{
    3 sage: var('y')
    4 y
    5 sage: declare_var('y')
    6 y
    7 sage: y = declare_var('y')
    8 sage: y
    9 sage: type(y)
    10 <type 'NoneType'>
    11 }}}
    12 Later, after all books are changed, `var` without return value should be phased out.
     1Functions returning a value should not have side effects, `var` does. In #17447, comment 23 Nils Bruin proposed to separate both usages of `var` by introducing `declare_var`: this should behave exactly like `var` without return value, and `var` should not put the var handle in the `globals` list but should act like `SR.var`. If we want the following behaviour:
     2 1. `declare_var('x')` == `var('x')` as before but returning `None`
     3 2. `var('x')` prints deprecation message, returns variable as before; error after deprecation period
     4 3. `y = var('x')` as before (but without globals), NO deprecation message
     5we certainly need the preparser to recognize 2/3, and to replace (2) with `declare_var('x'); deprecation(...); x` and (3) with `y = SR.var('x')`. Secondly, there is a different docstring needed with `var` when compared with `declare_var`.
    136
    147This and the same with functions is the most annoying problem for people doing calculus in Sage.
    158
    169 * http://ask.sagemath.org/question/8145/difference-between-varx-and-xvarx/
     10
     11Also #6559 deprecated the `ns` keyword 5 years ago, let's remove it from `var()`.