#17958: implement declare_var, deprecate (None)var
-----------------------------+------------------------
       Reporter:  rws        |        Owner:
           Type:  defect     |       Status:  new
       Priority:  major      |    Milestone:  sage-6.6
      Component:  symbolics  |   Resolution:
       Keywords:             |    Merged in:
        Authors:             |    Reviewers:
Report Upstream:  N/A        |  Work issues:
         Branch:             |       Commit:
   Dependencies:             |     Stopgaps:
-----------------------------+------------------------
Description changed by jdemeyer:

Old description:

> 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, and `var` should not put the var handle in the
> `globals` list but should act like `SR.var`. If we want the following
> behaviour:
>  1. `declare_var('x')` == `var('x')` as before but returning `None`
>  2. `var('x')` prints deprecation message, returns variable as before;
> error after deprecation period
>  3. `y = var('x')` as before (but without globals), NO deprecation
> message
> we 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`.
>
> This and the same with functions is the most annoying problem for people
> doing calculus in Sage.
>
>  * http://ask.sagemath.org/question/8145/difference-between-varx-and-
> xvarx/
>
> Also #6559 deprecated the `ns` keyword 5 years ago, let's remove it from
> `var()`.

New description:

 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, and `var` should not put the var handle in the `globals`
 list but should act like `SR.var`. If we want the following behaviour:
  1. `declare_var('x')` == `var('x')` as before but returning `None`
  2. `var('x')` prints deprecation message, returns variable as before;
 error after deprecation period
  3. `y = var('x')` as before (but without globals), NO deprecation message
 we 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`.

 This and the same with functions is the most annoying problem for people
 doing calculus in Sage.

  * http://ask.sagemath.org/question/8145/difference-between-varx-and-
 xvarx/

--

--
Ticket URL: <http://trac.sagemath.org/ticket/17958#comment:44>
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to