2 ;;; Auxiliary routines for OPTIMIZE'ing
4 ;;; Created by KMP 8:23pm Friday, 23 February 1979
8 ;;; FOPTIMIZE(A,B,[C,D],[Q]...);
10 ;;; Elements of the arg list with different forms do different things:
12 ;;; [1] If an arg is an ATOM, then its function will be redefined with the
15 ;;; [2] If the arg is a 1-length List, then the function named in the list
16 ;;; will be optimized, and the optimized LAMBDA will be returned.
18 ;;; [3] If the arg is a 2-length list, then the function named by its
19 ;;; first arg will be optimized and given the name of the second
20 ;;; element of the list.
23 ;;; $FOPTIMIZE is the name of the driver that gets called from Macsyma
25 (DEFUN $FOPTIMIZE FEXPR
(X) (CONS (NCONS 'MLIST
) (MAPCAR 'FOPTIMIZE X
)))
27 ;;; FOPTIMIZE is the function that does the work.
28 ;;; It does type checking but will only do interesting things with
29 ;;; ATOMS or MLIST's one or two long.
33 (*CATCH
'FOPTIMIZE-NO-MEXPR-DEFINITION
35 (FOPTIMIZE-AUX (MGET X
'MEXPR
) X
)
41 (NOT (EQ (CAAR X
) 'MLIST
))
42 (NOT (SYMBOLP (CADR X
)))
43 (NOT (SYMBOLP (CADDR X
))))
45 (PRINC '|;FOPTIMIZE called on an illegal form.| TYO
)
48 (LET (((IN OUT
) (CDR X
)) (DEF ()))
49 (*CATCH
'FOPTIMIZE-NO-MEXPR-DEFINITION
51 (SETQ DEF
(FOPTIMIZE-AUX (MGET IN
'MEXPR
) IN
))
52 (COND (OUT (MPUTPROP OUT DEF
'MEXPR
) OUT
)
56 ;;; This function is where the LAMBDA is actually optimized.
58 (DEFUN FOPTIMIZE-AUX
(DEF NAME
)
61 (PRINC '|;No function definition for | TYO
)
62 (PRINC (STRIPDOLLAR NAME
) TYO
)
63 (PRINC '|. It will be ignored.| TYO
)
64 (*THROW
'FOPTIMIZE-NO-MEXPR-DEFINITION
'$FAILED
)))
67 ($OPTIMIZE
(LIST* (NCONS 'MPROG
)
68 (NCONS (NCONS 'MLIST
))