Top
Back: Miscellaneous oddities
Forward: Non-commutative subsystem
FastBack:
FastForward:
Up: Tricks and pitfalls
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

6.5 Identifier resolution

In SINGULAR, an identifier (i.e., a "word") is resolved in the following way and order: It is checked for

  1. a reserved name (like ring, std, ...),
  2. a local variable (w.r.t. a procedure),
  3. a local ring variable (w.r.t. the current basering locally set in a procedure),
  4. a global ring variable (w.r.t. the current basering)
  5. a global variable,
  6. a monomial consisting of local ring variables written without operators,
  7. a monomial consisting of global ring variables written without operators.

Consequently, it is allowed to have general variables with the same name as ring variables. However, the above identifier resolution order must be kept in mind. Otherwise, surprising results may come up.

 
ring r=0,(x,y),dp;
int x;
x*y; // resolved product int*poly, i.e., 0*y
==> 0
xy; // "xy" is one identifier and resolved to monomial xy
==> xy

For these reasons, we strongly recommend not to use variables which have the same name(s) as ring variables.

Moroever, we strongly recommend not to use ring variables whose name is fully contained in (i.e., is a substring of) another name of a ring variable. Otherwise, effects like the following might occur:

 
ring r=0,(x, x1),dp; // name x is substring of name x1 !!!!!!!!!
x;x1;   // resolved polynomial x
==> x
==> x1
short=0; 2x1; // resolved to monomial 2*x^1 !!!!!!
==> 2*x
2*x1; // resolved to product 2 times x1
==> 2*x1


Top Back: Miscellaneous oddities Forward: Non-commutative subsystem FastBack: FastForward: Up: Tricks and pitfalls Top: Singular Manual Contents: Table of Contents Index: Index About: About this document
            User manual for Singular version 4.3.2, 2023, generated by texi2html.