Skip to content

implement declare_var, deprecate (None)var #17958

Open
@rwst

Description

@rwst

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.

CC: @nbruin @kcrisman

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/17958

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions