|
3.5.3 NamesSINGULAR is a strongly typed language. This means that all names (= identifiers) have to be declared prior to their use. For the general syntax of a declaration, see the description of declaration commands (see section General command syntax). See section Data types, for a description of SINGULAR’s data types.
See section typeof, for a short overview of possible types. To get information
on a name and the object named by it, the It is possible to redefine an already existing name if doing so does not change its type. A redefinition first sets the variable to the default value and then computes the expression. The difference between redefining and overwriting a variable is shown in the following example: int i=3; i=i+1; // overwriting i; → 4 int i=i+1; // redefinition → // ** redefining i ** i; → 1 User defined names should start with a letter and consist of letters and
digits only. As an exception to this rule, the characters ring R; int n=3; ideal j(3); ideal j(n); // is equivalent to the above → // ** redefining j(3) ** ideal j(2)=x; j(2..3); → j(2)[1]=x j(3)[1]=0 Names may not coincide with reserved names (keywords). Type
The most recently printed expression is available
under the special name ring r; ideal i=x2+y3,y3+z4; std(i); → _[1]=y3+x2 → _[2]=z4-x2 ideal k=_; k*k+x; → _[1]=y6+2x2y3+x4 → _[2]=y3z4+x2z4-x2y3-x4 → _[3]=z8-2x2z4+x4 → _[4]=x size(_[3]); → 3 A string_expression enclosed in int foo(1)=42; string bar="foo"; `bar+"(1)"`; → 42 |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |