File: basic.mac

package info (click to toggle)
maxima 5.9.1-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 32,272 kB
  • ctags: 14,123
  • sloc: lisp: 145,126; fortran: 14,031; tcl: 10,052; sh: 3,313; perl: 1,766; makefile: 1,748; ansic: 471; awk: 7
file content (33 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*-*-MACSYMA-*-*/

EVAL_WHEN([TRANSLATE,BATCH,DEMO],
          IF GET('SHAREM,'VERSION) = FALSE
             THEN LOAD(AUTOLO))$

HERALD_PACKAGE(BASIC)$


/* These are basic macros, nothing in here should call anything
   complicated. PUSH and POP here are the simple version
   which do not hack once-only evaluation. 
   I might say that these macros are around mostly so
   that the code for implementing the more complicated
   macros, including the once-only stuff, can be simpler.
*/

PROG1(STATEMENT1,[STATEMENTS])::=
 BUILDQ([STATEMENT1,STATEMENTS,LOCAL:?GENTEMP()],
        LAMBDA([LOCAL],SPLICE(STATEMENTS),LOCAL)(STATEMENT1))$

SYMBOLCHECK(X):=
 IF SYMBOLP(X) THEN X ELSE ERROR("Arg must be a symbol",X)$

PUSH(C,L)::=(SYMBOLCHECK(L),BUILDQ([C,L],L:CONS(C,L)))$

POP(L)::=(SYMBOLCHECK(L),BUILDQ([L],PROG1(FIRST(L),L:REST(L))))$

/* TR_EV is a pretty sorry way to get optimization
   by Translation-time evaluation. User directed constant-folding
   you might call it. TR_EV has other uses. */

TR_EV(X)::=BUILDQ([X],?MEVAL(X))$