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