aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/error.spad.pamphlet
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
committerdos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
commitab8cc85adde879fb963c94d15675783f2cf4b183 (patch)
treec202482327f474583b750b2c45dedfc4e4312b1d /src/algebra/error.spad.pamphlet
downloadopen-axiom-ab8cc85adde879fb963c94d15675783f2cf4b183.tar.gz
Initial population.
Diffstat (limited to 'src/algebra/error.spad.pamphlet')
-rw-r--r--src/algebra/error.spad.pamphlet139
1 files changed, 139 insertions, 0 deletions
diff --git a/src/algebra/error.spad.pamphlet b/src/algebra/error.spad.pamphlet
new file mode 100644
index 00000000..4f3c828f
--- /dev/null
+++ b/src/algebra/error.spad.pamphlet
@@ -0,0 +1,139 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/algebra error.spad}
+\author{Robert S. Sutor}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{package ERROR ErrorFunctions}
+<<package ERROR ErrorFunctions>>=
+)abbrev package ERROR ErrorFunctions
+++ Author: Robert S. Sutor
+++ Date Created: 29 May 1990
+++ Date Last Updated: 29 May 1990
+++ Description:
+++ ErrorFunctions implements error functions callable from the system
+++ interpreter. Typically, these functions would be called in user
+++ functions. The simple forms of the functions take one argument
+++ which is either a string (an error message) or a list of strings
+++ which all together make up a message. The list can contain
+++ formatting codes (see below). The more sophisticated versions takes
+++ two arguments where the first argument is the name of the function
+++ from which the error was invoked and the second argument is either a
+++ string or a list of strings, as above. When you use the one
+++ argument version in an interpreter function, the system will
+++ automatically insert the name of the function as the new first
+++ argument. Thus in the user interpreter function
+++ \spad{f x == if x < 0 then error "negative argument" else x}
+++ the call to error will actually be of the form
+++ \spad{error("f","negative argument")}
+++ because the interpreter will have created a new first argument.
+++
+++ Formatting codes: error messages may contain the following
+++ formatting codes (they should either start or end a string or
+++ else have blanks around them):
+++ \spad{%l} start a new line
+++ \spad{%b} start printing in a bold font (where available)
+++ \spad{%d} stop printing in a bold font (where available)
+++ \spad{ %ceon} start centering message lines
+++ \spad{%ceoff} stop centering message lines
+++ \spad{%rjon} start displaying lines "ragged left"
+++ \spad{%rjoff} stop displaying lines "ragged left"
+++ \spad{%i} indent following lines 3 additional spaces
+++ \spad{%u} unindent following lines 3 additional spaces
+++ \spad{%xN} insert N blanks (eg, \spad{%x10} inserts 10 blanks)
+++
+++ Examples:
+++ 1. \spad{error "Whoops, you made a %l %ceon %b big %d %ceoff %l mistake!"}
+++ 2. \spad{error ["Whoops, you made a","%l %ceon %b","big",
+++ "%d %ceoff %l","mistake!"]}
+
+ErrorFunctions() : Exports == Implementation where
+ Exports ==> with
+ error: String -> Exit
+ ++ error(msg) displays error message msg and terminates.
+ error: List String -> Exit
+ ++ error(lmsg) displays error message lmsg and terminates.
+ error: (String,String) -> Exit
+ ++ error(nam,msg) displays error message msg preceded by a
+ ++ message containing the name nam of the function in which
+ ++ the error is contained.
+ error: (String,List String) -> Exit
+ ++ error(nam,lmsg) displays error messages lmsg preceded by a
+ ++ message containing the name nam of the function in which
+ ++ the error is contained.
+ Implementation ==> add
+
+ prefix1 : String := "Error signalled from user code: %l "
+ prefix2 : String := "Error signalled from user code in function %b "
+
+ doit(s : String) : Exit ==
+ throwPatternMsg(s,nil$(List String))$Lisp
+ -- there are no objects of type Exit, so we'll fake one,
+ -- knowing we will never get to this step anyway.
+ "exit" pretend Exit
+
+ error(s : String) : Exit ==
+ doit concat [prefix1,s]
+
+ error(l : List String) : Exit ==
+ s : String := prefix1
+ for x in l repeat s := concat [s," ",x]
+ doit s
+
+ error(fn : String,s : String) : Exit ==
+ doit concat [prefix2,fn,": %d %l ",s]
+
+ error(fn : String, l : List String) : Exit ==
+ s : String := concat [prefix2,fn,": %d %l"]
+ for x in l repeat s := concat [s," ",x]
+ doit s
+
+@
+\section{License}
+<<license>>=
+--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+--All rights reserved.
+--
+--Redistribution and use in source and binary forms, with or without
+--modification, are permitted provided that the following conditions are
+--met:
+--
+-- - Redistributions of source code must retain the above copyright
+-- notice, this list of conditions and the following disclaimer.
+--
+-- - Redistributions in binary form must reproduce the above copyright
+-- notice, this list of conditions and the following disclaimer in
+-- the documentation and/or other materials provided with the
+-- distribution.
+--
+-- - Neither the name of The Numerical ALgorithms Group Ltd. nor the
+-- names of its contributors may be used to endorse or promote products
+-- derived from this software without specific prior written permission.
+--
+--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+@
+<<*>>=
+<<license>>
+
+<<package ERROR ErrorFunctions>>
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}