diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index 246a25b..cd1b36f 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -1244,7 +1244,7 @@ we return the remainder of the string without the leading prefix. (t (setq u (let (t0) - (do ((t1 l (CDR t1)) (y NIL)) + (do ((t1 l (cdr t1)) (y nil)) ((or (atom t1) (progn (setq y (car t1)) nil)) (nreverse0 t0)) (if (|stringPrefix?| (pname x) (pname y)) (setq t0 (cons y t0)))))) @@ -2498,11 +2498,11 @@ The value of the {\tt )set break} variable then controls what happens. (setq af1 ($findfile af '(|as| |spad| |ao| |asy|))) (cond ((and af1 (string= (|pathnameType| af1) "as")) - (|compileAsharpCmd| (CONS af1 NIL))) + (|compileAsharpCmd| (cons af1 nil))) ((and af1 (string= (|pathnameType| af1) "ao")) - (|compileAsharpCmd| (CONS af1 NIL))) + (|compileAsharpCmd| (cons af1 nil))) ((and af1 (string= (|pathnameType| af1) "spad")) - (|compileSpad2Cmd| (CONS af1 NIL))) + (|compileSpad2Cmd| (cons af1 nil))) ((and af1 (string= (|pathnameType| af1) "asy")) (|compileAsharpArchiveCmd| (cons af1 nil))) (t (|throwKeyedMsg| 's2iz0039 nil))))))))))))))))) @@ -2694,7 +2694,7 @@ The value of the {\tt )set break} variable then controls what happens. (cond ((|fnameReadable?| lsp) (unless bequiet - (|sayKeyedMsg| 's2iz0089 (cons (|namestring| lsp) NIL))) + (|sayKeyedMsg| 's2iz0089 (cons (|namestring| lsp) nil))) (|compileFileQuietly| lsp)) (t (|sayKeyedMsg| 's2il0003 (cons (|namestring| lsp) nil)))) (cond @@ -2993,35 +2993,6 @@ displayed. If the answer is either Y or YES we return true else nil. @ \defun{displayMacros}{displayMacros} -;displayMacros names == -; imacs := getInterpMacroNames() -; pmacs := getParserMacroNames() -; macros := -; null names => APPEND (imacs, pmacs) -; names -; macros := REMDUP macros -; null macros => sayBrightly '" There are no Axiom macros." -; -- first do user defined ones -; first := true -; for macro in macros repeat -; macro in pmacs => -; if first then -; sayBrightly ['%l,'"User-defined macros:"] -; first := NIL -; displayParserMacro macro -; macro in imacs => 'iterate -; sayBrightly ([" ",'%b, macro, '%d, " is not a known Axiom macro."]) -; -- now system ones -; first := true -; for macro in macros repeat -; macro in imacs => -; macro in pmacs => 'iterate -; if first then -; sayBrightly ['%l,'"System-defined macros:"] -; first := NIL -; displayMacro macro -; macro in pmacs => 'iterate -; NIL <>= (defun |displayMacros| (names) (let (imacs pmacs macros first) @@ -11418,7 +11389,7 @@ This reports the traced functions (cons 's2it0009 (cons (cons (strconc ")" (|object2String| key)) nil) nil)))))) - (key (|throwKeyedMsg| 's2it0005 (CONS key nil))))))))) + (key (|throwKeyedMsg| 's2it0005 (cons key nil))))))))) @ @@ -12836,7 +12807,7 @@ to convert the data into type "Expression" (cond ((|isFunctor| x) (|addTraceItem| x)) ((is_genvar x) (|addTraceItem| (EVAL x))) - (t (setq |functionList| (CONS x |functionList|))))) + (t (setq |functionList| (cons x |functionList|))))) (t (|userError| "bad argument to trace")))))) (setq |functionList| (prog (t1) @@ -12915,7 +12886,7 @@ to convert the data into type "Expression" (setq t7 (append t7 (|concat| '|, | (|abbreviate| x))))))))))) (cond ((atom |displayList|) - (setq |displayList| (CONS |displayList| nil)))) + (setq |displayList| (cons |displayList| nil)))) (|sayBrightly| " Parameterized constructors traced:") (|sayBrightly| (|flowSegmentedMsg| |displayList| $linelength 6))) (t nil))))))))) @@ -15545,28 +15516,6 @@ The \verb|$undoFlag| is used in recordFrame to decide whether to do undo recording. It is initially set to T in initvars. This is part of the undo mechanism. -\chapter{Makefile.bookvol5} -<<*>>= -LATEX=/usr/bin/latex -LISP=${AXIOM}/obj/linux/bin/lisp -TANGLE=/usr/local/bin/NOTANGLE -WEAVE=/usr/local/bin/NOWEAVE -delay - -all: bookvol5 - @echo 0 done - -bookvol5: bookvol5.pamphlet - @echo 1 extracting the bookvol5reter - ${WEAVE} bookvol5.pamphlet >bookvol5.tex - ${LATEX} bookvol5.tex - ${LATEX} bookvol5.tex - ${TANGLE} -R"Interpreter" bookvol5.pamphlet >bookvol5.lisp - -remake: - @echo 2 rebuilding the makefile - @${TANGLE} bookvol5.pamphlet >Makefile.bookvol5 - -@ \eject \begin{thebibliography}{99} \bibitem{1} Daly, Timothy, "The Axiom Literate Documentation"\\ diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 5daa933..b539dd1 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -4,102 +4,46 @@ \usepackage{makeidx} \makeindex \usepackage{graphicx} -% struggle with latex figure-floating behavior -\renewcommand\floatpagefraction{.9} -\renewcommand\topfraction{.9} -\renewcommand\bottomfraction{.9} -\renewcommand\textfraction{.1} -\setcounter{totalnumber}{50} -\setcounter{topnumber}{50} -\setcounter{bottomnumber}{50} - - -%% spadgraph are the actual text that you type at the axiom prompt for draw -\providecommand{\spadgraph}[1]% -{\begin{flushleft}{\tt #1}\end{flushleft}\vskip .1cm } - -% spadfunFrom records the function name and domain in the index -\providecommand{\spadfunFrom}[2]% -{{\bf #1}\index{#1 @\begingroup \string\bf{} #1 \endgroup}\index{#2}} - -%% spadsig gives the standard -> notation for signatures -\providecommand{\spadsig}[2]{{\sf #1 $\rightarrow$ #2}} - -% special meanings for math characters -\providecommand{\N}{\mbox{\bbold N}} -\providecommand{\Natural}{\mbox{\bbold N}} -\providecommand{\Z}{\mbox{\bbold Z}} -\providecommand{\Integer}{\mbox{\bbold Z}} -\providecommand{\Rational}{\mbox{\bbold Q}} -\providecommand{\Q}{\mbox{\bbold Q}} -\providecommand{\Complex}{\mbox{\bbold C}} -\providecommand{\C}{{\mathcal C}} -\providecommand{\Real}{\mbox{\bbold R}} -\providecommand{\F}{{\mathcal F}} -\providecommand{\R}{{\mathcal R}} - -% draw a box around a text block -\providecommand\boxed[2]{% -\begin{center} -\begin{tabular}{|c|} -\hline -\begin{minipage}{#1} -\normalsize -{#2} -\end{minipage}\\ -\hline -\end{tabular} -\end{center}} - -\providecommand{\optArg}[1]{{{\tt [}{#1}{\tt ]}}} -\providecommand{\argDef}[1]{{\tt ({#1})}} -\providecommand{\funSyntax}[2]{{\bf #1}{\tt ({\small\it{#2}})}} -\providecommand{\funArgs}[1]{{\tt ({\small\it {#1}})}\newline} -\providecommand{\condata}[4]{{\bf #1} {\bf #2} {\bf #3} {\bf #4}} - -\def\glossaryTerm#1{{\bf #1}\index{#1}} -\def\glossaryTermNoIndex#1{{\bf #1}} -\def\glossarySyntaxTerm#1{{\tt #1}\index{#1}} -\long\def\ourGloss#1#2{\par\pagebreak[3]{#1}\newline{#2}} -\def\csch{\mathop{\rm csch}\nolimits} - -\def\erf{\mathop{\rm erf}\nolimits} - -\def\zag#1#2{ - {{\hfill \left. {#1} \right|} - \over - {\left| {#2} \right. \hfill} - } -} - - -% these bitmaps are used by HyperDoc -\newdimen\commentWidth -\commentWidth=11pc -\newdimen\colGutterWidth -\colGutterWidth=1pc -\newdimen\baseLeftSkip -\baseLeftSkip=\commentWidth \advance\baseLeftSkip by \colGutterWidth - -\providecommand\ExitBitmap% -{{\setlength{\unitlength}{0.01in}% -\begin{picture}(50,16)(0,0)\special{psfile=ps/exit.ps}\end{picture}}} - -\providecommand\ReturnBitmap% -{{\setlength{\unitlength}{0.01in}% -\begin{picture}(50,16)(0,0)\special{psfile=ps/home.ps}\end{picture}}} - -\providecommand\HelpBitmap% -{{\setlength{\unitlength}{0.01in}% -\begin{picture}(50,16)(0,0)\special{psfile=ps/help.ps}\end{picture}}} - -\providecommand\UpBitmap% -{{\setlength{\unitlength}{0.01in}% -\begin{picture}(50,16)(0,0)\special{psfile=ps/up.ps}\end{picture}}} - -\providecommand{\tpd}[5]% -{{\setlength{\unitlength}{0.01in}% -\begin{picture}(#1,#2)(#3,#4)\special{psfile=#5}\end{picture}}} +%% +%% defun marks a function definition and adds it to the index +%% +\newcommand{\defun}[2]{% e.g. \defun{functionname} +\subsection{defun #2}% +\label{#1}% +\index{#1}% +\index{defun!#1}% +\index{#1!defun}} + +%% +%% defmacro marks a macro definition and adds it to the index +%% +\newcommand{\defmacro}[1]{% e.g. \defmacro{functionname} +\subsection{defmacro {#1}}% +\label{#1}% +\index{#1}% +\index{defmacro!#1}% +\index{#1!defmacro}} + +%% +%% defvar marks a var definition and adds it to the index +%% +\newcommand{\defvar}[1]{% e.g. \defvar{varname} +\subsection{defvar \${#1}}% +\label{#1}% +\index{#1}% +\index{defvar!#1}% +\index{#1!defvar}} + + +%% +%% defdollar marks a var definition (with leading $) and adds it to the index +%% +\newcommand{\defdollar}[1]{% e.g. \defdollar{functionname} +\subsection{defvar \${#1}}% +\label{#1}% +\index{\${#1}}% +\index{defvar!\${#1}}% +\index{\${#1}!defvar}} \begin{document} \begin{titlepage} @@ -303,18 +247,402 @@ This book is actually a literate program\cite{2} and can contain executable source code. In particular, the Makefile for this book is part of the source of the book and is included below. Axiom uses the ``noweb'' literate programming system by Norman Ramsey\cite{6}. -<<*>>= -PROJECT=bookvol9 -TANGLE=/usr/local/bin/NOTANGLE -WEAVE=/usr/local/bin/NOWEAVE -LATEX=/usr/bin/latex -MAKEINDEX=/usr/bin/makeindex - -all: - ${WEAVE} -t8 -delay ${PROJECT}.pamphlet >${PROJECT}.tex - ${LATEX} ${PROJECT}.tex 2>/dev/null 1>/dev/null - ${MAKEINDEX} ${PROJECT}.idx - ${LATEX} ${PROJECT}.tex 2>/dev/null 1>/dev/null +\chapter{Compiler top level} +\section{)compile} +This is the implementation of the )compile command. + +You use this command to invoke the new Axiom library compiler or the +old Axiom system compiler. The {\tt )compile} system command is +actually a combination of Axiom processing and a call to the Aldor +compiler. It is performing double-duty, acting as a front-end to both +the Aldor compiler and the old Axiom system compiler. (The old Axiom +system compiler was written in Lisp and was an integral part of the +Axiom environment. The Aldor compiler is written in C and executed by +the operating system when called from within Axiom.) + +\par\noindent{\bf User Level Required:} compiler + +\par\noindent{\bf Command Syntax:} + +\begin{list}{} +\item {\tt )compile} +\item {\tt )compile {\it fileName}} +\item {\tt )compile {\it fileName}.spad} +\item {\tt )compile {\it directory/fileName}.spad} +\item {\tt )compile {\it fileName} )old} +\item {\tt )compile {\it fileName} )translate} +\item {\tt )compile {\it fileName} )quiet} +\item {\tt )compile {\it fileName} )noquiet} +\item {\tt )compile {\it fileName} )moreargs} +\item {\tt )compile {\it fileName} )onlyargs} +\item {\tt )compile {\it fileName} )break} +\item {\tt )compile {\it fileName} )nobreak} +\item {\tt )compile {\it fileName} )library} +\item {\tt )compile {\it fileName} )nolibrary} +\item {\tt )compile {\it fileName} )vartrace} +\item {\tt )compile {\it fileName} )constructor} {\it nameOrAbbrev} +\end{list} + +These command forms invoke the Aldor compiler. +\begin{list}{} +\item {\tt )compile {\it fileName}.as} +\item {\tt )compile {\it directory/fileName}.as} +\item {\tt )compile {\it fileName}.ao} +\item {\tt )compile {\it directory/fileName}.ao} +\item {\tt )compile {\it fileName}.al} +\item {\tt )compile {\it directory/fileName}.al} +\item {\tt )compile {\it fileName}.lsp} +\item {\tt )compile {\it directory/fileName}.lsp} +\item {\tt )compile {\it fileName} )new} +\end{list} + +\par\noindent{\bf Command Description:} + +The first thing {\tt )compile} does is look for a source code +filename among its arguments. +Thus +\begin{verbatim} +)compile mycode.spad +)compile /u/jones/mycode.spad +)compile mycode +\end{verbatim} +all invoke {\tt )compiler} on the file {\tt +/u/jones/mycode.spad} if the current Axiom working +directory is {\tt /u/jones.} (Recall that you can set the +working directory via the {\tt )cd} command. If you don't set it +explicitly, it is the directory from which you started +Axiom.) + +If you omit the file extension, the command looks to see if you have +specified the {\tt )new} or {\tt )old} option. If you have given one +of these options, the corresponding compiler is used. + +The command first looks in the standard system directories for files +with extension {\it .as, .ao} and {\it .al} and then files with +extension {\it .spad}. The first file found has the appropriate +compiler invoked on it. If the command cannot find a matching file, +an error message is displayed and the command terminates. + +The first thing {\tt )compile} does is look for a source code +filename among its arguments. +Thus +\begin{verbatim} +)compile mycode.as +)compile /u/jones/as/mycode.as +)compile mycode +\end{verbatim} +all invoke {\tt )compiler} on the file {\tt +/u/jones/as/mycode.as} if the current Axiom working +directory is {\tt /u/jones/as.} (Recall that you can set the +working directory via the {\tt )cd} command. If you don't set it +explicitly, it is the directory from which you started +Axiom.) + +This is frequently all you need to compile your file. + +This simple command: +\begin{enumerate} +\item Invokes the chosen compiler and produces Lisp output. +\item Calls the Lisp compiler if the compilation was +successful. +\item Uses the {\tt )library} command to tell Axiom about +the contents of your compiled file and arrange to have those +contents loaded on demand. +\end{enumerate} + +Should you not want the {\tt )library} command automatically +invoked, call {\tt )compile} with the {\tt )nolibrary} option. +For example, +\begin{verbatim} +)compile mycode )nolibrary +\end{verbatim} + +By default, the {\tt )library} system command {\it exposes} all +domains and categories it processes. +This means that the Axiom intepreter will consider those +domains and categories when it is trying to resolve a reference +to a function. +Sometimes domains and categories should not be exposed. +For example, a domain may just be used privately by another +domain and may not be meant for top-level use. +The {\tt )library} command should still be used, though, so that +the code will be loaded on demand. +In this case, you should use the {\tt )nolibrary} option on {\tt +)compile} and the {\tt )noexpose} option in the {\tt )library} +command. For example, +\begin{verbatim} +)compile mycode )nolibrary +)library mycode )noexpose +\end{verbatim} + +Once you have established your own collection of compiled code, +you may find it handy to use the {\tt )dir} option on the +{\tt )library} command. +This causes {\tt )library} to process all compiled code in the +specified directory. For example, +\begin{verbatim} +)library )dir /u/jones/quantum +\end{verbatim} +You must give an explicit directory after {\tt )dir}, even if you +want all compiled code in the current working directory +processed, e.g. +\begin{verbatim} +)library )dir . +\end{verbatim} + +\subsection{Spad compiler} +This command compiles files with file extension {\tt .spad} +with the old Axiom system compiler. + +The {\tt )translate} option is used to invoke a special version of the +old system compiler that will translate a {\it .spad} file to a {\it +.as} file. That is, the {\it .spad} file will be parsed and analyzed +and a file using the new syntax will be created. + +By default, the {\it .as} file is created in the same directory as the +{\it .spad} file. If that directory is not writable, the current +directory is used. If the current directory is not writable, an error +message is given and the command terminates. Note that {\tt )translate} +implies the {\tt )old} option so the file extension can +safely be omitted. If {\tt )translate} is given, all other options are +ignored. Please be aware that the translation is not necessarily one +hundred percent complete or correct. You should attempt to compile +the output with the Aldor compiler and make any necessary corrections. + +You can compile category, domain, and package constructors contained +in files with file extension {\it .spad}. You can compile individual +constructors or every constructor in a file. + +The full filename is remembered between invocations of this command and +{\tt )edit} commands. The sequence of commands +\begin{verbatim} +)compile matrix.spad +)edit +)compile +\end{verbatim} +will call the compiler, edit, and then call the compiler again on the +file {\bf matrix.spad.} If you do not specify a {\it directory,} the +working current directory is searched for the file. If the file is +not found, the standard system directories are searched. + +If you do not give any options, all constructors within a file are +compiled. Each constructor should have an {\tt )abbreviation} command +in the file in which it is defined. We suggest that you place the +{\tt )abbreviation} commands at the top of the file in the order in +which the constructors are defined. + +The {\tt )library} option causes directories containing the compiled +code for each constructor to be created in the working current +directory. The name of such a directory consists of the constructor +abbreviation and the {\bf .nrlib} file extension. For example, the +directory containing the compiled code for the {\tt MATRIX} +constructor is called {\bf MATRIX.nrlib.} The {\tt )nolibrary} option +says that such files should not be created. The default is +{\tt )library.} Note that the semantics of {\tt )library} and +{\tt )nolibrary} for the new Aldor compiler and for the old system +compiler are completely different. + +The {\tt )vartrace} option causes the compiler to generate +extra code for the constructor to support conditional tracing of +variable assignments. (see +\ref{ugSysCmdtrace} on page~\pageref{ugSysCmdtrace}). Without +this option, this code is suppressed and one cannot use +the {\tt )vars} option for the trace command. + +The {\tt )constructor} option is used to +specify a particular constructor to compile. +All other constructors in the file are ignored. +The constructor name or abbreviation follows {\tt )constructor.} +Thus either +\begin{verbatim} +)compile matrix.spad )constructor RectangularMatrix +\end{verbatim} +or +\begin{verbatim} +)compile matrix.spad )constructor RMATRIX +\end{verbatim} +compiles the {\tt RectangularMatrix} constructor +defined in {\bf matrix.spad.} + +The {\tt )break} and {\tt )nobreak} options determine what +the spad compiler does when it encounters an error. +{\tt )break} is the default and it indicates that processing +should stop at the first error. +The value of the {\tt )set break} variable then controls what happens. + +\subsection{Aldor compiler} +This command compiles files with file extensions {\it .as, .ao} and +{\it .al} with the Aldor compiler. It also can compile files +with file extension {\it .lsp}. These are assumed to be Lisp files +genererated by the Aldor compiler. + +The general description of Aldor command line arguments is in +the Aldor documentation. +The default options used by the {\tt )compile} command can be +viewed and set using the {\tt )set compiler args} Axiom +system command. +The current defaults are +\begin{verbatim} +-O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom +\end{verbatim} +These options mean: +\begin{itemize} +\item {\tt -O}: perform all optimizations, +\item {\tt -Fasy}: generate a {\tt .asy} file, +\item {\tt -Fao}: generate a {\tt .ao} file, +\item {\tt -Flsp}: generate a {\tt .lsp} (Lisp) file, +\item {\tt -laxiom}: use the {\tt axiom} library {\tt libaxiom.al}, +\item {\tt -Mno-AXL\_W\_WillObsolete}: do not display messages +about older generated files becoming obsolete, and +\item {\tt -DAxiom}: define the global assertion {\tt Axiom} so that the +Aldor libraries for generating stand-alone code +are not accidentally used with Axiom. +\end{itemize} + +To supplement these default arguments, use the {\tt )moreargs} option on +{\tt )compile.} +For example, +\begin{verbatim} +)compile mycode.as )moreargs "-v" +\end{verbatim} +uses the default arguments and appends the {\tt -v} (verbose) +argument flag. +The additional argument specification {\bf must be enclosed in +double quotes.} + +To completely replace these default arguments for a particular +use of {\tt )compile}, use the {\tt )onlyargs} option. +For example, +\begin{verbatim} +)compile mycode.as )onlyargs "-v -O" +\end{verbatim} +only uses the {\tt -v} (verbose) and {\tt -O} (optimize) +arguments. +The argument specification {\bf must be enclosed in double quotes.} +In this example, Lisp code is not produced and so the compilation +output will not be available to Axiom. + +To completely replace the default arguments for all calls to {\tt +)compile} within your Axiom session, use {\tt )set compiler args.} +For example, to use the above arguments for all compilations, issue +\begin{verbatim} +)set compiler args "-v -O" +\end{verbatim} +Make sure you include the necessary {\tt -l} and {\tt -Y} +arguments along with those needed for Lisp file creation. +As above, {\bf the argument specification must be enclosed in double +quotes.} + +The {\tt )compile} command works with several file extensions. We saw +above what happens when it is invoked on a file with extension {\tt +.as.} A {\tt .ao} file is a portable binary compiled version of a +{\tt .as} file, and {\tt )compile} simply passes the {\tt .ao} file +onto Aldor. The generated Lisp file is compiled and {\tt )library} +is automatically called, just as if you had specified a {\tt .as} file. + +A {\tt .al} file is an archive file containing {\tt .ao} files. The +archive is created (on Unix systems) with the {\tt ar} program. When +{\tt )compile} is given a {\tt .al} file, it creates a directory whose +name is based on that of the archive. For example, if you issue +\begin{verbatim} +)compile mylib.al +\end{verbatim} +the directory {\tt mylib.axldir} is created. All members of the +archive are unarchived into the directory and {\tt )compile} is called +on each {\tt .ao} file found. It is your responsibility to remove the +directory and its contents, if you choose to do so. + +A {\tt .lsp} file is a Lisp source file, generated by Aldor +when called with the {\tt -Flsp} option. When {\tt )compile} is used +with a {\tt .lsp} file, the Lisp file is compiled and {\tt )library} +is called. For Aldor, You must also have present a {\tt .asy} +generated from the same source file. + +\defun{compileSpad2Cmd}{The Spad compiler top level function} +This is the old compiler. +Assume we entered from the "compiler" function, so args is +a file with file extension .spad. + +The \verb|$f| and \verb|$m| are compiler variables, probably function +and mode. +<>= +(defun |compileSpad2Cmd| (args) + (let (|$newcompMode| |$ncConverse| |$newComp| |$scanIfTrue| + |$compileOnlyCertainItems| |$f| |$m| |$QuickLet| |$QuickCode| + |$sourceFileTypes| |$InteractiveMode| path optlist fun optname + optargs fullopt translateoldtonew constructor) + (declare (special |$newcompMode| |$ncConverse| |$newComp| |$scanIfTrue| + |$compileOnlyCertainItems| |$f| |$m| |$QuickLet| |$QuickCode| + |$sourceFileTypes| |$InteractiveMode| /editfile |$options| + |$newConlist|)) + (setq path (|pathname| args)) + (cond + ((nequal (|pathnameType| path) "spad") (|throwKeyedMsg| 'S2IZ0082 nil)) + ((null (probe-file path)) + (|throwKeyedMsg| 's2il0003 (cons (|namestring| args) nil))) + (t + (setq /editfile path) + (|updateSourceFiles| path) + (|sayKeyedMsg| 's2iz0038 (list (|namestring| args))) + (setq optlist '(|break| |constructor| |functions| |library| |lisp| + |new| |old| |nobreak| |nolibrary| |noquiet| |vartrace| |quiet| + |translate|)) + (setq |$QuickLet| t) + (setq |$QuickCode| t) + (setq fun '(|rq| |lib|)) + (setq |$sourceFileTypes| '("SPAD")) + (dolist (opt |$options|) + (setq optname (car opt)) + (setq optargs (cdr opt)) + (setq fullopt (|selectOptionLC| optname optlist nil)) + (case fullopt + (|new| (|error| '|Internal error: compileSpad2Cmd got )new|)) + (|old| nil) + (|translate| (setq translateoldtonew t)) + (|library| (setelt fun 1 '|lib|)) + (|nolibrary| (setelt fun 1 '|nolib|)) + (|quiet| (when (nequal (elt fun 0) '|c|) (setelt fun 0 '|rq|))) + (|noquiet| (when (nequal (elt fun 0) '|c|) (setelt fun 0 '|rf|))) + (|nobreak| (setq |$scanIfTrue| t)) + (|break| (setq |$scanIfTrue| nil)) + (|vartrace| (setq |$QuickLet| nil)) + (|lisp| (|throwKeyedMsg| 's2iz0036 (list ")lisp"))) + (|functions| + (if (null optargs) + (|throwKeyedMsg| 's2iz0037 (list ")functions")) + (setq |$compileOnlyCertainItems| optargs))) + (|constructor| + (if (null optargs) + (|throwKeyedMsg| 's2iz0037 (list ")constructor")) + (progn + (setelt fun 0 '|c|) + (setq constructor (mapcar #'|unabbrev| optargs))))) + (t + (|throwKeyedMsg| 's2iz0036 + (list (strconc ")" (|object2String| optname))))))) + (setq |$InteractiveMode| nil) + (cond + (translateoldtonew + (|oldParserAutoloadOnceTrigger|) + (|browserAutoloadOnceTrigger|) + (|spad2AsTranslatorAutoloadOnceTrigger|) + (|sayKeyedMsg| 's2iz0085 nil) + (|convertSpadToAsFile| path)) + (|$compileOnlyCertainItems| + (if (null constructor) + (|sayKeyedMsg| 's2iz0040 nil) + (|compilerDoitWithScreenedLisplib| constructor fun))) + (t (|compilerDoit| constructor fun))) + (|extendLocalLibdb| |$newConlist|) + (|terminateSystemCommand|) + (|spadPrompt|))))) + +@ +\chapter{The Compiler} +<>= +(in-package "BOOT") + +<> @ \eject @@ -339,5 +667,6 @@ Literate Programming''\\ \bibitem{7} Daly, Timothy, "The Axiom Literate Documentation"\\ {\bf http://axiom.axiom-developer.org/axiom-website/documentation.html} \end{thebibliography} +\chapter{Index} \printindex \end{document} diff --git a/changelog b/changelog index 92ae214..d2c57aa 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +20090327 tpd src/axiom-website/patches.html 20090327.01.tpd.patch +20090327 tpd src/interp/util.lisp stop autoloading compiler root +20090327 tpd src/interp/Makefile build bookvol9 +20090327 tpd src/Makefile copy bookvol9 to src/interp +20090327 tpd books/bookvol9 create compiler root +20090327 tpd src/interp/compiler.boot move compiler root to bookvol9 +20090327 tpd books/bookvol5 move compiler root to bookvol9 20090326 tpd src/axiom-website/patches.html 20090326.01.tpd.patch 20090326 tpd books/bookvol4 Finding Anonymous Function Signatures 20090325 tpd src/axiom-website/patches.html 20090325.01.tpd.patch diff --git a/src/Makefile.pamphlet b/src/Makefile.pamphlet index a48ac4b..3d60ea8 100644 --- a/src/Makefile.pamphlet +++ b/src/Makefile.pamphlet @@ -249,6 +249,10 @@ and {\bf interpsys}. Since these two images share a lot of files they are built in the interp subdirectory using the same Makefile. +Book Volume 5 contains the interpreter. + +Book Volume 9 contains the compiler. + <>= interpdir: ${SRC}/interp/Makefile @echo 25 making ${SRC}/interp @@ -260,6 +264,7 @@ interpdir: ${SRC}/interp/Makefile @mkdir -p ${MNT}/${SYS}/doc/msgs @mkdir -p ${MNT}/${SYS}/doc/src/interp @cp ${SPD}/books/bookvol5.pamphlet interp + @cp ${SPD}/books/bookvol9.pamphlet interp @(cd interp ; ${ENV} ${MAKE} ) ${SRC}/interp/Makefile: ${SRC}/interp/Makefile.pamphlet diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 9d8fe52..4ec4d96 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -1028,5 +1028,7 @@ In process, not yet released

download.html add March 2009 column, add fedora10 binary
20090326.01.tpd.patch bookvol4 Finding Anonymous Function Signatures
+20090327.01.tpd.patch +bookvol9 create compiler root
diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet index d0a819c..0f2f801 100644 --- a/src/interp/Makefile.pamphlet +++ b/src/interp/Makefile.pamphlet @@ -183,6 +183,7 @@ OBJS= ${OUT}/vmlisp.${O} ${OUT}/hash.${O} \ ${OUT}/i-code.${O} ${OUT}/i-coerce.${O} \ ${OUT}/i-coerfn.${O} ${OUT}/i-eval.${O} \ ${OUT}/i-funsel.${O} ${OUT}/bookvol5.${O} \ + ${OUT}/bookvol9.${O} \ ${OUT}/i-intern.${O} ${OUT}/i-map.${O} \ ${OUT}/i-output.${O} ${OUT}/i-resolv.${O} \ ${OUT}/i-spec1.${O} \ @@ -4368,32 +4369,34 @@ ${MID}/bookvol5.${LISP}: ${IN}/bookvol5.pamphlet ${TANGLE} -RInterpreter ${IN}/bookvol5.pamphlet >bookvol5.${LISP} ) @ -The new bookvol5 now depends on some pictures in the src/doc/ps -subdirectory so we have to extend the preconditions to include this. -<>= -${DOC}/bookvol5.dvi: ${IN}/bookvol5.pamphlet ${DOC}/ps - @echo 299 making ${DOC}/bookvol5.dvi from ${IN}/bookvol5.pamphlet - @(cd ${DOC} ; \ - cp ${IN}/bookvol5.pamphlet ${DOC} ; \ - ${DOCUMENT} ${NOISE} bookvol5 ; \ - rm -f ${DOC}/bookvol5.pamphlet ; \ - rm -f ${DOC}/bookvol5.tex ; \ - rm -f ${DOC}/bookvol5 ) +\subsection{bookvol9.lsp} +<>= +${OUT}/bookvol9.${O}: ${MID}/bookvol9.${LISP} + @ echo 297 making ${OUT}/bookvol9.${O} from ${MID}/bookvol9.${LISP} + @ (cd ${MID} ; \ + if [ -z "${NOISE}" ] ; then \ + echo '(progn (compile-file "${MID}/bookvol9.${LISP}"' \ + ':output-file "${OUT}/bookvol9.${O}") (${BYE}))' | ${DEPSYS} ; \ + else \ + echo '(progn (compile-file "${MID}/bookvol9.${LISP}"' \ + ':output-file "${OUT}/bookvol9.${O}") (${BYE}))' | ${DEPSYS} \ + >${TMP}/trace ; \ + fi ) @ -<>= -${BOOK}/bookvol5.dvi: ${DOC}/bookvol5.dvi - @echo 299 making ${BOOK}/bookvol5.dvi from ${DOC}/bookvol5.dvi - @ cp ${DOC}/bookvol5.dvi ${BOOK}/bookvol5.dvi +<>= +${OUT}/bookvol9.${LISP}: ${MID}/bookvol9.${LISP} + @ echo 133 making ${OUT}/bookvol9.${LISP} from ${MID}/bookvol9.${LISP} + @cp ${MID}/bookvol9.${LISP} ${OUT}/bookvol9.${LISP} @ -<>= -${DOC}/ps: ${SRC}/doc/ps - @echo 299a making ${DOC}/ps from ${SRC}/doc/ps - @cp -pr ${SRC}/doc/ps ${DOC} +<>= +${MID}/bookvol9.${LISP}: ${IN}/bookvol9.pamphlet + @ echo 298 making ${MID}/bookvol9.${LISP} from ${IN}/bookvol9.pamphlet + @ (cd ${MID} ; \ + ${TANGLE} -RCompiler ${IN}/bookvol9.pamphlet >bookvol9.${LISP} ) @ - \subsection{i-intern.boot} <>= ${OUT}/i-intern.${O}: ${MID}/i-intern.clisp @@ -8748,10 +8751,10 @@ clean: <> <> <> -<> -<> -<> +<> +<> +<> <> <> diff --git a/src/interp/compiler.boot.pamphlet b/src/interp/compiler.boot.pamphlet index 4deb2b2..d1be1e7 100644 --- a/src/interp/compiler.boot.pamphlet +++ b/src/interp/compiler.boot.pamphlet @@ -1651,417 +1651,6 @@ modeEqualSubst(m1,m,e) == nil @ -\section{)compile} -This is the implementation of the )compile command. - -You use this command to invoke the new Axiom library compiler or the -old Axiom system compiler. The {\tt )compile} system command is -actually a combination of Axiom processing and a call to the Aldor -compiler. It is performing double-duty, acting as a front-end to both -the Aldor compiler and the old Axiom system compiler. (The old Axiom -system compiler was written in Lisp and was an integral part of the -Axiom environment. The Aldor compiler is written in C and executed by -the operating system when called from within Axiom.) - -\par\noindent{\bf User Level Required:} compiler - -\par\noindent{\bf Command Syntax:} - -\begin{list}{} -\item {\tt )compile} -\item {\tt )compile {\it fileName}} -\item {\tt )compile {\it fileName}.spad} -\item {\tt )compile {\it directory/fileName}.spad} -\item {\tt )compile {\it fileName} )old} -\item {\tt )compile {\it fileName} )translate} -\item {\tt )compile {\it fileName} )quiet} -\item {\tt )compile {\it fileName} )noquiet} -\item {\tt )compile {\it fileName} )moreargs} -\item {\tt )compile {\it fileName} )onlyargs} -\item {\tt )compile {\it fileName} )break} -\item {\tt )compile {\it fileName} )nobreak} -\item {\tt )compile {\it fileName} )library} -\item {\tt )compile {\it fileName} )nolibrary} -\item {\tt )compile {\it fileName} )vartrace} -\item {\tt )compile {\it fileName} )constructor} {\it nameOrAbbrev} -\end{list} - -These command forms invoke the Aldor compiler. -\begin{list}{} -\item {\tt )compile {\it fileName}.as} -\item {\tt )compile {\it directory/fileName}.as} -\item {\tt )compile {\it fileName}.ao} -\item {\tt )compile {\it directory/fileName}.ao} -\item {\tt )compile {\it fileName}.al} -\item {\tt )compile {\it directory/fileName}.al} -\item {\tt )compile {\it fileName}.lsp} -\item {\tt )compile {\it directory/fileName}.lsp} -\item {\tt )compile {\it fileName} )new} -\end{list} - -\par\noindent{\bf Command Description:} - -The first thing {\tt )compile} does is look for a source code -filename among its arguments. -Thus -\begin{verbatim} -)compile mycode.spad -)compile /u/jones/mycode.spad -)compile mycode -\end{verbatim} -all invoke {\tt )compiler} on the file {\tt -/u/jones/mycode.spad} if the current Axiom working -directory is {\tt /u/jones.} (Recall that you can set the -working directory via the {\tt )cd} command. If you don't set it -explicitly, it is the directory from which you started -Axiom.) - -If you omit the file extension, the command looks to see if you have -specified the {\tt )new} or {\tt )old} option. If you have given one -of these options, the corresponding compiler is used. - -The command first looks in the standard system directories for files -with extension {\it .as, .ao} and {\it .al} and then files with -extension {\it .spad}. The first file found has the appropriate -compiler invoked on it. If the command cannot find a matching file, -an error message is displayed and the command terminates. - -The first thing {\tt )compile} does is look for a source code -filename among its arguments. -Thus -\begin{verbatim} -)compile mycode.as -)compile /u/jones/as/mycode.as -)compile mycode -\end{verbatim} -all invoke {\tt )compiler} on the file {\tt -/u/jones/as/mycode.as} if the current Axiom working -directory is {\tt /u/jones/as.} (Recall that you can set the -working directory via the {\tt )cd} command. If you don't set it -explicitly, it is the directory from which you started -Axiom.) - -This is frequently all you need to compile your file. - -This simple command: -\begin{enumerate} -\item Invokes the chosen compiler and produces Lisp output. -\item Calls the Lisp compiler if the compilation was -successful. -\item Uses the {\tt )library} command to tell Axiom about -the contents of your compiled file and arrange to have those -contents loaded on demand. -\end{enumerate} - -Should you not want the {\tt )library} command automatically -invoked, call {\tt )compile} with the {\tt )nolibrary} option. -For example, -\begin{verbatim} -)compile mycode )nolibrary -\end{verbatim} - -By default, the {\tt )library} system command {\it exposes} all -domains and categories it processes. -This means that the Axiom intepreter will consider those -domains and categories when it is trying to resolve a reference -to a function. -Sometimes domains and categories should not be exposed. -For example, a domain may just be used privately by another -domain and may not be meant for top-level use. -The {\tt )library} command should still be used, though, so that -the code will be loaded on demand. -In this case, you should use the {\tt )nolibrary} option on {\tt -)compile} and the {\tt )noexpose} option in the {\tt )library} -command. For example, -\begin{verbatim} -)compile mycode )nolibrary -)library mycode )noexpose -\end{verbatim} - -Once you have established your own collection of compiled code, -you may find it handy to use the {\tt )dir} option on the -{\tt )library} command. -This causes {\tt )library} to process all compiled code in the -specified directory. For example, -\begin{verbatim} -)library )dir /u/jones/quantum -\end{verbatim} -You must give an explicit directory after {\tt )dir}, even if you -want all compiled code in the current working directory -processed, e.g. -\begin{verbatim} -)library )dir . -\end{verbatim} - -\subsection{Spad compiler} -This command compiles files with file extension {\tt .spad} -with the old Axiom system compiler. - -The {\tt )translate} option is used to invoke a special version of the -old system compiler that will translate a {\it .spad} file to a {\it -.as} file. That is, the {\it .spad} file will be parsed and analyzed -and a file using the new syntax will be created. - -By default, the {\it .as} file is created in the same directory as the -{\it .spad} file. If that directory is not writable, the current -directory is used. If the current directory is not writable, an error -message is given and the command terminates. Note that {\tt )translate} -implies the {\tt )old} option so the file extension can -safely be omitted. If {\tt )translate} is given, all other options are -ignored. Please be aware that the translation is not necessarily one -hundred percent complete or correct. You should attempt to compile -the output with the Aldor compiler and make any necessary corrections. - -You can compile category, domain, and package constructors contained -in files with file extension {\it .spad}. You can compile individual -constructors or every constructor in a file. - -The full filename is remembered between invocations of this command and -{\tt )edit} commands. The sequence of commands -\begin{verbatim} -)compile matrix.spad -)edit -)compile -\end{verbatim} -will call the compiler, edit, and then call the compiler again on the -file {\bf matrix.spad.} If you do not specify a {\it directory,} the -working current directory is searched for the file. If the file is -not found, the standard system directories are searched. - -If you do not give any options, all constructors within a file are -compiled. Each constructor should have an {\tt )abbreviation} command -in the file in which it is defined. We suggest that you place the -{\tt )abbreviation} commands at the top of the file in the order in -which the constructors are defined. - -The {\tt )library} option causes directories containing the compiled -code for each constructor to be created in the working current -directory. The name of such a directory consists of the constructor -abbreviation and the {\bf .nrlib} file extension. For example, the -directory containing the compiled code for the {\tt MATRIX} -constructor is called {\bf MATRIX.nrlib.} The {\tt )nolibrary} option -says that such files should not be created. The default is -{\tt )library.} Note that the semantics of {\tt )library} and -{\tt )nolibrary} for the new Aldor compiler and for the old system -compiler are completely different. - -The {\tt )vartrace} option causes the compiler to generate -extra code for the constructor to support conditional tracing of -variable assignments. (see -\ref{ugSysCmdtrace} on page~\pageref{ugSysCmdtrace}). Without -this option, this code is suppressed and one cannot use -the {\tt )vars} option for the trace command. - -The {\tt )constructor} option is used to -specify a particular constructor to compile. -All other constructors in the file are ignored. -The constructor name or abbreviation follows {\tt )constructor.} -Thus either -\begin{verbatim} -)compile matrix.spad )constructor RectangularMatrix -\end{verbatim} -or -\begin{verbatim} -)compile matrix.spad )constructor RMATRIX -\end{verbatim} -compiles the {\tt RectangularMatrix} constructor -defined in {\bf matrix.spad.} - -The {\tt )break} and {\tt )nobreak} options determine what -the spad compiler does when it encounters an error. -{\tt )break} is the default and it indicates that processing -should stop at the first error. -The value of the {\tt )set break} variable then controls what happens. - -\subsection{Aldor compiler} -This command compiles files with file extensions {\it .as, .ao} and -{\it .al} with the Aldor compiler. It also can compile files -with file extension {\it .lsp}. These are assumed to be Lisp files -genererated by the Aldor compiler. - -The general description of Aldor command line arguments is in -the Aldor documentation. -The default options used by the {\tt )compile} command can be -viewed and set using the {\tt )set compiler args} Axiom -system command. -The current defaults are -\begin{verbatim} --O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -\end{verbatim} -These options mean: -\begin{itemize} -\item {\tt -O}: perform all optimizations, -\item {\tt -Fasy}: generate a {\tt .asy} file, -\item {\tt -Fao}: generate a {\tt .ao} file, -\item {\tt -Flsp}: generate a {\tt .lsp} (Lisp) file, -\item {\tt -laxiom}: use the {\tt axiom} library {\tt libaxiom.al}, -\item {\tt -Mno-AXL\_W\_WillObsolete}: do not display messages -about older generated files becoming obsolete, and -\item {\tt -DAxiom}: define the global assertion {\tt Axiom} so that the -Aldor libraries for generating stand-alone code -are not accidentally used with Axiom. -\end{itemize} - -To supplement these default arguments, use the {\tt )moreargs} option on -{\tt )compile.} -For example, -\begin{verbatim} -)compile mycode.as )moreargs "-v" -\end{verbatim} -uses the default arguments and appends the {\tt -v} (verbose) -argument flag. -The additional argument specification {\bf must be enclosed in -double quotes.} - -To completely replace these default arguments for a particular -use of {\tt )compile}, use the {\tt )onlyargs} option. -For example, -\begin{verbatim} -)compile mycode.as )onlyargs "-v -O" -\end{verbatim} -only uses the {\tt -v} (verbose) and {\tt -O} (optimize) -arguments. -The argument specification {\bf must be enclosed in double quotes.} -In this example, Lisp code is not produced and so the compilation -output will not be available to Axiom. - -To completely replace the default arguments for all calls to {\tt -)compile} within your Axiom session, use {\tt )set compiler args.} -For example, to use the above arguments for all compilations, issue -\begin{verbatim} -)set compiler args "-v -O" -\end{verbatim} -Make sure you include the necessary {\tt -l} and {\tt -Y} -arguments along with those needed for Lisp file creation. -As above, {\bf the argument specification must be enclosed in double -quotes.} - -The {\tt )compile} command works with several file extensions. We saw -above what happens when it is invoked on a file with extension {\tt -.as.} A {\tt .ao} file is a portable binary compiled version of a -{\tt .as} file, and {\tt )compile} simply passes the {\tt .ao} file -onto Aldor. The generated Lisp file is compiled and {\tt )library} -is automatically called, just as if you had specified a {\tt .as} file. - -A {\tt .al} file is an archive file containing {\tt .ao} files. The -archive is created (on Unix systems) with the {\tt ar} program. When -{\tt )compile} is given a {\tt .al} file, it creates a directory whose -name is based on that of the archive. For example, if you issue -\begin{verbatim} -)compile mylib.al -\end{verbatim} -the directory {\tt mylib.axldir} is created. All members of the -archive are unarchived into the directory and {\tt )compile} is called -on each {\tt .ao} file found. It is your responsibility to remove the -directory and its contents, if you choose to do so. - -A {\tt .lsp} file is a Lisp source file, generated by Aldor -when called with the {\tt -Flsp} option. When {\tt )compile} is used -with a {\tt .lsp} file, the Lisp file is compiled and {\tt )library} -is called. For Aldor, You must also have present a {\tt .asy} -generated from the same source file. - -\subsection{compileSpad2Cmd} -<<*>>= -compileSpad2Cmd args == - -- This is the old compiler - -- Assume we entered from the "compiler" function, so args ^= nil - -- and is a file with file extension .spad. - - path := pathname args - pathnameType path ^= '"spad" => throwKeyedMsg("S2IZ0082", nil) - ^PROBE_-FILE path => throwKeyedMsg("S2IL0003",[namestring args]) - - SETQ(_/EDITFILE, path) - updateSourceFiles path - sayKeyedMsg("S2IZ0038",[namestring args]) - - optList := '( _ - break _ - constructor _ - functions _ - library _ - lisp _ - new _ - old _ - nobreak _ - nolibrary _ - noquiet _ - vartrace _ - quiet _ - translate _ - ) - - -- next three are for the OLD NEW compiler - -- should be unhooked - - $newcompMode : local := nil - $ncConverse : local := nil - $newComp : local := nil - - translateOldToNew := nil - - $scanIfTrue : local := nil - $compileOnlyCertainItems : local := nil - $f : local := nil -- compiler - $m : local := nil -- variables - - -- following are for )quick option for code generation - $QuickLet : local := true - $QuickCode : local := true - - fun := ['rq, 'lib] - constructor := nil - $sourceFileTypes : local := '("SPAD") - - for opt in $options repeat - [optname,:optargs] := opt - fullopt := selectOptionLC(optname,optList,nil) - - fullopt = 'new => error "Internal error: compileSpad2Cmd got )new" - fullopt = 'old => NIL -- no opt - fullopt = 'translate => translateOldToNew := true - - fullopt = 'library => fun.1 := 'lib - fullopt = 'nolibrary => fun.1 := 'nolib - - -- Ignore quiet/nonquiet if "constructor" is given. - fullopt = 'quiet => if fun.0 ^= 'c then fun.0 := 'rq - fullopt = 'noquiet => if fun.0 ^= 'c then fun.0 := 'rf - fullopt = 'nobreak => $scanIfTrue := true - fullopt = 'break => $scanIfTrue := nil - fullopt = 'vartrace => - $QuickLet := false - fullopt = 'lisp => - throwKeyedMsg("S2IZ0036",['")lisp"]) - fullopt = 'functions => - null optargs => - throwKeyedMsg("S2IZ0037",['")functions"]) - $compileOnlyCertainItems := optargs - fullopt = 'constructor => - null optargs => - throwKeyedMsg("S2IZ0037",['")constructor"]) - fun.0 := 'c - constructor := [unabbrev o for o in optargs] - throwKeyedMsg("S2IZ0036",[STRCONC('")",object2String optname)]) - - $InteractiveMode : local := nil - if translateOldToNew then - oldParserAutoloadOnceTrigger() - browserAutoloadOnceTrigger() - spad2AsTranslatorAutoloadOnceTrigger() - sayKeyedMsg("S2IZ0085", nil) - convertSpadToAsFile path - else if $compileOnlyCertainItems then - null constructor => sayKeyedMsg("S2IZ0040",NIL) - compilerDoitWithScreenedLisplib(constructor, fun) - else - compilerDoit(constructor, fun) - extendLocalLibdb $newConlist - terminateSystemCommand() - spadPrompt() - -@ \subsection{convertSpadToAsFile} <<*>>= convertSpadToAsFile path == diff --git a/src/interp/util.lisp.pamphlet b/src/interp/util.lisp.pamphlet index a754b43..962138b 100644 --- a/src/interp/util.lisp.pamphlet +++ b/src/interp/util.lisp.pamphlet @@ -373,7 +373,7 @@ developers who write or modify algebra code. '( ;; loadcompiler |oldCompilerAutoloadOnceTrigger| - |compileSpad2Cmd| +;; |compileSpad2Cmd| |convertSpadToAsFile| |compilerDoit| |compilerDoitWithScreenedLisplib|