[Next] [Prev] [Right] [Left] [Up] [Index] [Root]
Automatic Printing

Automatic Printing

Magma now allows automatic printing of expressions: basically, a statement consisting of an expression (or list of expressions) alone is taken as a shorthand for the print statement.

Subsections

Semantics

Some subtleties are involved in understanding the precise behaviour of Magma in interpreting lone expressions as statements. The rules Magma follows are outlined here. In the following, a call-form means any expression of the form f(( arguments)); that is, anything which could be a procedure call or a function call.


Example Lang_auto-print (H1E9)

Examples which illustrate point (a):

> 1;
1
> x := 3;
> x;
3
Examples which illustrate point (b):

> 1 + 1;                  // really function call '+'(1, 1)
2
> Q := [ 0 ];
> Append( Q, 1);          // first (in fact only) match is procedure call
> Append(Q, 1);           // first (in fact only) match is function call
[ 0, 1, 1 ]
> // Assuming fp is assigned to a procedure or function:
> fp(x);                  // whichever fp is at runtime
> SetVerbose("Meataxe", true);  // simple procedure call
Examples which illustrate point (c):

> 1, 2;
1 2
> // Assuming f assigned:
> f(x), 1;                            // f only can be a function
> SetVerbose("Meataxe", true), 1;     // type error in 'SetVerbose'
>                                     // (since no function form)
Examples which illustrate point (d):

> 1: Magma;
1
> Sym(3), []: Maximal;
Symmetric group acting on a set of cardinality 3
Order = 6 = 2 * 3
[]
> SetVerbose("Meataxe", true): Magma; // type error as above
Examples which illustrate point (e):

> 1;
1
> $1;
1
> 2, 3;
2 3
> $1;
2 3
> Quotrem(124124, 123);
1009 17
> $1;
1009 17
> a, b := $1;
> a;
1009

The Previous Value Buffer

Magma also provides a few procedures to manipulate the previous value buffer in which $1, etc. are stored.

ShowPrevious() : ->
(Procedure.) Show all the previous values stored.
ShowPrevious(i) : RngIntElt ->
(Procedure.) Show the i-th previous value stored.
ClearPrevious() : ->
(Procedure.) Clear all the previous values stored. This is useful for making sure that no more memory is used up than what the current identifiers refer to.
SetPreviousSize(n) : RngIntElt ->
(Procedure.) Set the size of the previous value buffer (this is not how many values are defined in it at the moment, but the maximum number that will be stored). The default size is 3.
GetPreviousSize() : -> RngIntElt
Return the size of the previous value buffer.
[Next] [Prev] [Right] [Left] [Up] [Index] [Root]