1 Hints for compiling macsyma code.
5 Definition: The list of variables in the first argument of a LAMBDA
6 construct are defined to be lambda-bound within the lexical scope
7 of the rest of the arguments of the LAMBDA, which called the body of the
8 LAMBDA. This same term applies to the formal parameters of a function,
9 which is also called a lambda list, and the constructs BLOCK,
10 SUM, PRODUCT, and DO (also called FOR).
14 LAMBDA([U,[L]], A*U*L /* U and L are bound here, A is not */);
16 F(X):= (/* X is bound here */, X^2);
18 SUM(J^N, /* J is bound here */
20 J^2, /* J is not bound here */
23 Definition: If a variable in an expression is not bound lexicaly by
24 a LAMBDA construct, it is called a global variable.
26 Hint #1: All global variables should be introduced with a DEFINE_VARIABLE.
28 DEFINE_VARIABLE(name,default_initial_value,mode,"documentation string");
30 The mode can be one of FIXNUM, FLOAT, BOOLEAN, or ANY.
31 If the variable only takes on the values TRUE and FALSE, and its
32 used in the construct IF name THEN this ELSE that; then it
33 is commonly called a switch, and is of BOOLEAN mode.
34 The FIXNUM and FLOAT modes set things up to make sure that
35 the user only sets the variable legal fixnums (integers), and floating-point
36 (real), numbers respectively. There can also be a gain in the efficiency
37 of evaluating numerical expressions when the variables are of known
38 fixnum or float modes. Efficiency is gained when it is know that
39 the limits of DOloop's, SUM's, and PRODUCT's are FIXNUM.
40 ANY mode specifies no information about the variables
45 A modedeclaration can be given for lambda bound variables as
46 the first expression within the scope of the lambda construct
47 in which they are bound. e.g.
49 F(X,Y,Z):=(MODEDECLARE([X,Y],FLOAT,Z,FIXNUM), X+Y+Z );
52 /* within the Block it is too late to modedeclare Q */
53 MODEDECLARE(SUM,FIXNUM), /* however here SUM can be declared. */
54 SUM:Q, SUM:SUM+Q, SUM);
56 MAPLIST(LAMBDA([U],MODEDECLARE(U,BOOLEAN), IF U THEN PRINT("FOO")), LIST);
59 Exceptions: SUM, PRODUCT and DO figure out the mode of the index by
60 looking at the modes of the limits.