Top
Back: 6.3 Miscellaneous oddities
Forward: A. Examples
FastBack: 6. Tricks and pitfalls
FastForward: A. Examples
Up: 6. Tricks and pitfalls
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

6.4 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 variable,
  5. a global ring variable (w.r.t. the current basering)
  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.

Moreover, 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 poly 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: 6.3 Miscellaneous oddities Forward: A. Examples FastBack: 6. Tricks and pitfalls FastForward: A. Examples Up: 6. Tricks and pitfalls Top: Singular 2-0-4 Manual Contents: Table of Contents Index: F. Index About: About This Document
            User manual for Singular version 2-0-4, October 2002, generated by texi2html.