diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index 5e06258..a9ce007 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -33253,7 +33253,7 @@ Evaluates the arguments passed to a constructor \calls{evaluateType1}{bottumUp} \calls{evaluateType1}{qcar} \calls{evaluateType1}{qcdr} -\calls{evaluateType1}{getAndEvalConstructorArguments} +\calls{evaluateType1}{getAndEvalConstructorArgument} \calls{evaluateType1}{coerceOrRetract} \calls{evaluateType1}{objValUnwrap} \calls{evaluateType1}{throwKeyedMsgCannotCoerceWithValue} @@ -34666,6 +34666,131 @@ o )library \end{chunk} +\chapter{Handlers for Special Forms} +This file contains the functions which do type analysis and +evaluation of special functions in the interpreter. +Special functions are ones which are not defined in the algebra +code, such as assignment, construct, COLLECT and declaration. + +Operators which require special handlers all have a LISP ``up'' +property which is the name of the special handler, which is +always the word ``up'' followed by the operator name. +If an operator has this ``up'' property the handler is called +automatically from bottomUp instead of general modemap selection. + +The up handlers are usually split into two pieces, the first is +the up function itself, which performs the type analysis, and an +``eval'' function, which generates (and executes, if required) the +code for the function. + +The up functions always take a single argument, which is the +entire attributed tree for the operation, and return the modeSet +of the node, which is a singleton list containing the type +computed for the node. + +The eval functions can take any arguments deemed necessary. +Actual evaluation is done if \verb|$genValue| is true, otherwise code is +generated. + +(See the function analyzeMap for other things that may affect +what is generated in these functions.) + +These functions are required to do two things: +\begin{enumerate} +\item do a putValue on the operator vector with the computed value + of the node, which is a triple. This is usually done in the + eval functions. +\item do a putModeSet on the operator vector with a list of the + computed type of the node. This is usually done in the + up functions. +\end{enumerate} + +There are several special modes used in these functions: +\begin{enumerate} +\item Void is the mode that should be used for all statements + that do not otherwise return values, such as declarations, + loops, IF-THEN's without ELSE's, etc.. +\item \verb|$NoValueMode| and \verb|$ThrowAwayMode| used to be used + in situations where Void is now used, and are being phased out + completely. +\end{enumerate} + +\defun{getAndEvalConstructorArgument}{getAndEvalConstructorArgument} +\calls{getAndEvalConstructorArgument}{getValue} +\calls{getAndEvalConstructorArgument}{objMode} +\calls{getAndEvalConstructorArgument}{isWrapped} +\calls{getAndEvalConstructorArgument}{objVal} +\calls{getAndEvalConstructorArgument}{isLocalVar} +\calls{getAndEvalConstructorArgument}{compFailure} +\calls{getAndEvalConstructorArgument}{objNewWrap} +\calls{getAndEvalConstructorArgument}{timedEVALFUN} +\begin{chunk}{defun getAndEvalConstructorArgument} +(defun |getAndEvalConstructorArgument| (tree) + (let (triple) + (setq triple (|getValue| tree)) + (cond + ((eq (|objMode| triple) '(|Domain|)) triple) + ((|isWrapped| (|objVal| triple)) triple) + ((|isLocalVar| (|objVal| triple)) + (|compFailure| " Local variable or parameter used in type")) + (t + (|objNewWrap| (|timedEVALFUN| (|objVal| triple)) (|objMode| triple)))))) + +\end{chunk} + +\defun{replaceSharps}{replaceSharps} +Replaces all sharps in x by the arguments of domain d. +Replaces all replaces the triangle variables +\calls{replaceSharps}{subCopy} +\refsdollar{replaceSharps}{TriangleVariableList} +\refsdollar{replaceSharps}{FormalMapVariableList} +\begin{chunk}{defun replaceSharps} +(defun |replaceSharps| (x d) + (let (sl) + (declare (special |$TriangleVariableList| |$FormalMapVariableList|)) + (loop for e in (rest d) for var in |$FormalMapVariableList| + do (setq sl (cons (cons var e) sl))) + (setq x (|subCopy| x sl)) + (setq sl nil) + (loop for e in (rest d) for var in |$TriangleVariableList| + do (setq sl (cons (cons var e) sl))) + (|subCopy| x sl))) + +\end{chunk} + +\defun{isDomainValuedVariable}{isDomainValuedVariable} +Returns the value of form if form is a variable with a type value +\calls{isDomainValuedVariable}{identp} +\calls{isDomainValuedVariable}{get} +\calls{isDomainValuedVariable}{member} +\calls{isDomainValuedVariable}{objMode} +\calls{isDomainValuedVariable}{objValUnwrap} +\refsdollar{isDomainValuedVariable}{e} +\refsdollar{isDomainValuedVariable}{env} +\refsdollar{isDomainValuedVariable}{InteractiveFrame} +\begin{chunk}{defun isDomainValuedVariable} +(defun |isDomainValuedVariable| (form) + (let (val) + (declare (special |$e| |$env| |$InteractiveFrame|)) + (when (and (identp form) + (setq val + (or (|get| form '|value| |$InteractiveFrame|) + (and (consp |$env|) (|get| form '|value| |$env|)) + (and (consp |$e|) (|get| form '|value| |$e|)))) + (|member| (|objMode| val) '((|Domain|) (|SubDomain| (|Domain|))))) + (|objValUnwrap| val)))) + +\end{chunk} + +\defun{evalCategory}{evalCategory} +\calls{evalCategory}{ofCategory} +\calls{evalCategory}{isPartialMode} +\begin{chunk}{defun evalCategory} +(defun |evalCategory| (d c) + (or (|isPartialMode| d) (|ofCategory| d c))) + +\end{chunk} + \chapter{Handling input files} \defun{readSpadProfileIfThere}{Handle .axiom.input file} \uses{readSpadProfileIfThere}{/editfile} @@ -38063,6 +38188,14 @@ but the Axiom semantics are not the same. Because Axiom was originally written in Maclisp, then VMLisp, and then Common Lisp some of these old semantics survive. +\section{Void} +\defun{voidValue}{voidValue} +\begin{chunk}{defun voidValue} +(defun |voidValue| () "()") + +\end{chunk} + + \section{U32Vector} \defun{getrefv32}{getrefv32} \begin{chunk}{defun getrefv32} @@ -43015,6 +43148,7 @@ This needs to work off the internal exposure list, not the file. \getchunk{defun erMsgCompare} \getchunk{defun erMsgSep} \getchunk{defun erMsgSort} +\getchunk{defun evalCategory} \getchunk{defun evalDomain} \getchunk{defun evaluateSignature} \getchunk{defun evaluateType} @@ -43045,6 +43179,7 @@ This needs to work off the internal exposure list, not the file. \getchunk{defun genDomainTraceName} \getchunk{defun gensymInt} \getchunk{defun getAliasIfTracedMapParameter} +\getchunk{defun getAndEvalConstructorArgument} \getchunk{defun getAndSay} \getchunk{defun getBpiNameIfTracedMap} \getchunk{defun getBrowseDatabase} @@ -43160,6 +43295,7 @@ This needs to work off the internal exposure list, not the file. \getchunk{defun ioclear} \getchunk{defun iostat} \getchunk{defun isDomainOrPackage} +\getchunk{defun isDomainValuedVariable} \getchunk{defun isExposedConstructor} \getchunk{defun isgenvar} \getchunk{defun isInterpOnlyMap} @@ -43792,6 +43928,7 @@ This needs to work off the internal exposure list, not the file. \getchunk{defun removeTracedMapSigs} \getchunk{defun removeUndoLines} \getchunk{defun replaceFile} +\getchunk{defun replaceSharps} \getchunk{defun reportOperations} \getchunk{defun reportOpsFromLisplib} \getchunk{defun reportOpsFromLisplib0} @@ -44019,6 +44156,7 @@ This needs to work off the internal exposure list, not the file. \getchunk{defun validateOutputDirectory} \getchunk{defun vec2list} +\getchunk{defun voidValue} \getchunk{defun what} \getchunk{defun whatCommands} diff --git a/changelog b/changelog index 1f22232..6864876 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,8 @@ +20111108 tpd src/axiom-website/patches.html 20111108.02.tpd.patch +20111108 tpd src/interp/i-spec1.lisp treeshake interpreter +20111108 tpd books/bookvol5 treeshake interpreter +20111108 tpd src/axiom-website/patches.html 20111108.01.tpd.patch +20011108 tpd src/axiom-website/documentation.html add Knuth quote 20111107 tpd src/axiom-website/patches.html 20111107.01.tpd.patch 20111107 tpd books/bookvolbib add references 20111106 tpd src/axiom-website/patches.html 20111106.04.tpd.patch diff --git a/src/axiom-website/documentation.html b/src/axiom-website/documentation.html index 14cb5e7..f6a5831 100644 --- a/src/axiom-website/documentation.html +++ b/src/axiom-website/documentation.html @@ -208,6 +208,36 @@ trustworthy or interesting. TUG 2010

+From a November, 2011 Knuth interview: +

+
+ +

+Yet to me, literate programming is certainly the most important thing +that came out of the TeX project. Not only has it enabled me to write +and maintain programs faster and more reliably than ever before, and +been one of my greatest sources of joy since the 1980s -- it has +actually been indispensable at times. Some of my major programs, such +as the MMIX meta-simulator, could not have been written with any other +methodology that I've ever heard of. The complexity was simply too +daunting for my limited brain to handle; without literate programming, +the whole enterprise would have flopped miserably. +

+
+

+If people discover nice ways to use the newfangled multithreaded +machines, I would expect the discovery to come from people who +routinely use literate programming. Literate programming is what you +need to rise above the ordinary level of achievement. But I don't +believe in forcing ideas on anybody. +

+
+
+
+-- Knuth, Donald + +Interview with Donald Knuth +



diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 4689ded..7ba6ba9 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3672,5 +3672,9 @@ src/interp/vmlisp.lisp remove GETREFV
books/bookvol5 OpenMath support
20111107.01.tpd.patch books/bookvolbib add references
+20111108.01.tpd.patch +src/axiom-website/documentation.html add Knuth quote
+20111108.02.tpd.patch +books/bookvol5 treeshake interpreter
diff --git a/src/interp/i-spec1.lisp.pamphlet b/src/interp/i-spec1.lisp.pamphlet index 0b1c064..58d679c 100644 --- a/src/interp/i-spec1.lisp.pamphlet +++ b/src/interp/i-spec1.lisp.pamphlet @@ -81,10 +81,6 @@ There are several special modes used in these functions: |typeOf| |where|)) ;--% Void stuff -;voidValue() == '"()" - -(DEFUN |voidValue| () "()") - ;--% Handlers for Anonymous Function Definitions ;upADEF t == ; t isnt [.,[vars,types,.,body],pred,.] => NIL @@ -4833,102 +4829,6 @@ There are several special modes used in these functions: ((|isPartialMode| |mode|) (|throwKeyedMsg| 'S2IM0004 NIL)) ('T (|putHist| |var| '|mode| |mode| |$e|)))))) -;getAndEvalConstructorArgument tree == -; triple := getValue tree -; objMode triple = '(Domain) => triple -; isWrapped objVal(triple) => triple -; isLocalVar objVal triple => compFailure('" Local variable or parameter used in type") -; objNewWrap(timedEVALFUN objVal(triple), objMode(triple)) - -(DEFUN |getAndEvalConstructorArgument| (|tree|) - (PROG (|triple|) - (RETURN - (PROGN - (SPADLET |triple| (|getValue| |tree|)) - (COND - ((BOOT-EQUAL (|objMode| |triple|) '(|Domain|)) |triple|) - ((|isWrapped| (|objVal| |triple|)) |triple|) - ((|isLocalVar| (|objVal| |triple|)) - (|compFailure| - " Local variable or parameter used in type")) - ('T - (|objNewWrap| (|timedEVALFUN| (|objVal| |triple|)) - (|objMode| |triple|)))))))) - -;replaceSharps(x,d) == -; -- replaces all sharps in x by the arguments of domain d -; -- all replaces the triangle variables -; SL:= NIL -; for e in CDR d for var in $FormalMapVariableList repeat -; SL:= CONS(CONS(var,e),SL) -; x := subCopy(x,SL) -; SL:= NIL -; for e in CDR d for var in $TriangleVariableList repeat -; SL:= CONS(CONS(var,e),SL) -; subCopy(x,SL) - -(DEFUN |replaceSharps| (|x| |d|) - (PROG (SL) - (declare (special |$TriangleVariableList| |$FormalMapVariableList|)) - (RETURN - (SEQ (PROGN - (SPADLET SL NIL) - (DO ((G169241 (CDR |d|) (CDR G169241)) (|e| NIL) - (G169242 |$FormalMapVariableList| (CDR G169242)) - (|var| NIL)) - ((OR (ATOM G169241) - (PROGN (SETQ |e| (CAR G169241)) NIL) - (ATOM G169242) - (PROGN (SETQ |var| (CAR G169242)) NIL)) - NIL) - (SEQ (EXIT (SPADLET SL (CONS (CONS |var| |e|) SL))))) - (SPADLET |x| (|subCopy| |x| SL)) - (SPADLET SL NIL) - (DO ((G169255 (CDR |d|) (CDR G169255)) (|e| NIL) - (G169256 |$TriangleVariableList| (CDR G169256)) - (|var| NIL)) - ((OR (ATOM G169255) - (PROGN (SETQ |e| (CAR G169255)) NIL) - (ATOM G169256) - (PROGN (SETQ |var| (CAR G169256)) NIL)) - NIL) - (SEQ (EXIT (SPADLET SL (CONS (CONS |var| |e|) SL))))) - (|subCopy| |x| SL)))))) - -;isDomainValuedVariable form == -; -- returns the value of form if form is a variable with a type value -; IDENTP form and (val := ( -; get(form,'value,$InteractiveFrame) or _ -; (CONSP($env) and get(form,'value,$env)) or _ -; (CONSP($e) and get(form,'value,$e)))) and -; objMode(val) in '((Domain) (SubDomain (Domain))) => -; objValUnwrap(val) -; nil - -(DEFUN |isDomainValuedVariable| (|form|) - (PROG (|val|) - (declare (special |$e| |$env| |$InteractiveFrame|)) - (RETURN - (COND - ((AND (IDENTP |form|) - (SPADLET |val| - (OR (|get| |form| '|value| |$InteractiveFrame|) - (AND (CONSP |$env|) - (|get| |form| '|value| |$env|)) - (AND (CONSP |$e|) - (|get| |form| '|value| |$e|)))) - (|member| (|objMode| |val|) - '((|Domain|) (|SubDomain| (|Domain|))))) - (|objValUnwrap| |val|)) - ('T NIL))))) - -;evalCategory(d,c) == -; -- tests whether domain d has category c -; isPartialMode d or ofCategory(d,c) - -(DEFUN |evalCategory| (|d| |c|) - (OR (|isPartialMode| |d|) (|ofCategory| |d| |c|))) - ;isOkInterpMode m == ; isPartialMode(m) => isLegitimateMode(m,nil,nil) ; isValidType(m) and isLegitimateMode(m,nil,nil)