Top
Back: 4. Data types
Forward: 4.1.1 def declarations
FastBack: 4. Data types
FastForward: 5. Functions and system variables
Up: 4. Data types
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

4.1 def

Objects may be defined without a specific type: they get their type from the first assignment to them. E.g., ideal i=x,y,z; def j=i^2; defines the ideal i^2 with the name j.

Note: Unlike other assignments a ring as an untyped object is not a copy but another reference to the same (possibly unnamed) ring. This means that entries in one of these rings appear also in the other ones. The following defines a ring s which is just another reference (or name) for the basering r.

 
  ring r=32003,(x,y,z),dp;
  poly f = x;
  def s=basering;
  setring s;
  nameof(basering);
→ s
  listvar();
→ // s                    [0]  *ring
→ //      f                    [0]  poly
→ // r                    [0]  ring
→ // LIB                  [0]  string standard.lib
  poly g = y;
  kill f;
  listvar(r);
→ // r                    [0]  ring
→ // g                    [0]  poly
  ring t=32003,(u,w),dp;
  def rt=r+t;
  rt;
→ //   characteristic : 32003
→ //   number of vars : 5
→ //        block   1 : ordering dp
→ //                  : names    x y z 
→ //        block   2 : ordering dp
→ //                  : names    u w 
→ //        block   3 : ordering C

This reference to a ring with def is useful if the basering is not local to the procedure (so it cannot be accessed by its name) but one needs a name for it (e.g., for a use with setring or map). setring r; does not work in this case, because r may not be local to the procedure.


Top Back: 4. Data types Forward: 4.1.1 def declarations FastBack: 4. Data types FastForward: 5. Functions and system variables Up: 4. Data types 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.