Home Online Manual
Back: bigintmat operations
Forward: def declarations
FastBack: bigintmat
FastForward: ideal
Up: Data types
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.4 def

Objects may be defined without a specific type: they inherit 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. The name basering is an alias for the current ring.

  ring r=32003,(x,y,z),dp;
  poly f = x;
  def s=basering;
  setring s;
==> s
==> // s                              [0]  *ring
==> //      f                              [0]  poly
==> // r                              [0]  ring(*)
  poly g = y;
  kill f;
==> // r                              [0]  ring(*)
==> // g                              [0]  poly
  ring t=32003,(u,w),dp;
  def rt=r+t;
==> // coefficients: ZZ/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.

4.4.1 def declarations