aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-06-20 10:42:25 +0000
committerdos-reis <gdr@axiomatics.org>2011-06-20 10:42:25 +0000
commite4656a0388e8fa12594788b216b42bb04680d9d5 (patch)
tree3eb1e106e8344ca276b44fae4a489c0813efa92a /src
parente1925b37c7601d37bfa5d624d428ea40f3708c8f (diff)
downloadopen-axiom-e4656a0388e8fa12594788b216b42bb04680d9d5.tar.gz
* interp/spaderror.lisp ($numericFailure): Remove.
(trapNumericErrors): Define for non-GCL RTS. Tidy GCL-based definition. * algebra/draw.spad.pamphlet: trapNumericErrors now returns a value of type Maybe T. * algebra/plot.spad.pamphlet: Likewise. * algebra/plot3d.spad.pamphlet: Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/algebra/draw.spad.pamphlet16
-rw-r--r--src/algebra/plot.spad.pamphlet6
-rw-r--r--src/algebra/plot3d.spad.pamphlet9
-rw-r--r--src/interp/spaderror.lisp34
5 files changed, 39 insertions, 36 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f72f62e3..cd288cbc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,15 @@
2011-06-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/spaderror.lisp ($numericFailure): Remove.
+ (trapNumericErrors): Define for non-GCL RTS.
+ Tidy GCL-based definition.
+ * algebra/draw.spad.pamphlet: trapNumericErrors now returns a
+ value of type Maybe T.
+ * algebra/plot.spad.pamphlet: Likewise.
+ * algebra/plot3d.spad.pamphlet: Likewise.
+
+2011-06-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* Makefile.am (OA_GRAPHICS_TARGETS): Fix thinko.
2011-06-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
diff --git a/src/algebra/draw.spad.pamphlet b/src/algebra/draw.spad.pamphlet
index b5e7bae8..f145330d 100644
--- a/src/algebra/draw.spad.pamphlet
+++ b/src/algebra/draw.spad.pamphlet
@@ -318,10 +318,10 @@ TopLevelDrawFunctionsForCompiledFunctions():
myTrap1: (SF-> SF, SF) -> SF
myTrap1(ff:SF-> SF, f:SF):SF ==
- s := trapNumericErrors(ff(f))$Lisp :: Union(SF, "failed")
- s case "failed" => quietDoubleNaN()$Foreign(Builtin)
- r:=s::SF
- r >max()$SF or r < min()$SF => quietDoubleNaN()$Foreign(Builtin)
+ s: Maybe SF := trapNumericErrors(ff(f))$Lisp
+ s case nothing => quietDoubleNaN()$Foreign(Builtin)
+ r := s@SF
+ r > max()$SF or r < min()$SF => quietDoubleNaN()$Foreign(Builtin)
r
makePt2: (SF,SF) -> Point SF
@@ -493,10 +493,10 @@ TopLevelDrawFunctionsForCompiledFunctions():
myTrap2: ((SF, SF) -> SF, SF, SF) -> SF
myTrap2(ff:(SF, SF) -> SF, u:SF, v:SF):SF ==
- s := trapNumericErrors(ff(u, v))$Lisp :: Union(SF, "failed")
- s case "failed" => quietDoubleNaN()$Foreign(Builtin)
- r:SF := s::SF
- r >max()$SF or r < min()$SF => quietDoubleNaN()$Foreign(Builtin)
+ s: Maybe SF := trapNumericErrors(ff(u, v))$Lisp
+ s case nothing => quietDoubleNaN()$Foreign(Builtin)
+ r := s@SF
+ r > max()$SF or r < min()$SF => quietDoubleNaN()$Foreign(Builtin)
r
recolor(ptFunc,colFunc) ==
diff --git a/src/algebra/plot.spad.pamphlet b/src/algebra/plot.spad.pamphlet
index d03da277..664e3036 100644
--- a/src/algebra/plot.spad.pamphlet
+++ b/src/algebra/plot.spad.pamphlet
@@ -476,9 +476,9 @@ Plot(): Exports == Implementation where
myTrap: (F-> F, F) -> F
myTrap(ff:F-> F, f:F):F ==
- s := trapNumericErrors(ff(f))$Lisp :: Union(F, "failed")
- s case "failed" => quietDoubleNaN()$Lisp
- r:F:=s::F
+ s: Maybe F := trapNumericErrors(ff(f))$Lisp
+ s case nothing => quietDoubleNaN()$Lisp
+ r:F := s@F
r > max()$F or r < min()$F => quietDoubleNaN()$Lisp
r
diff --git a/src/algebra/plot3d.spad.pamphlet b/src/algebra/plot3d.spad.pamphlet
index aa98d794..1ea091a3 100644
--- a/src/algebra/plot3d.spad.pamphlet
+++ b/src/algebra/plot3d.spad.pamphlet
@@ -445,12 +445,9 @@ Plot3D(): Exports == Implementation where
myTrap: (F-> F, F) -> F
myTrap(ff:F-> F, f:F):F ==
- s := trapNumericErrors(ff(f))$Lisp :: Union(F, "failed")
- if (s) case "failed" then
- r:F := quietDoubleNaN()$Lisp
- else
- r:F := s
- r
+ s: Maybe F := trapNumericErrors(ff(f))$Lisp
+ s case nothing => quietDoubleNaN()$Lisp
+ s
plot(f1:F -> F,f2:F -> F,f3:F -> F,col:F -> F,tRange:R) ==
p := basicPlot(point(myTrap(f1,#1),myTrap(f2,#1),myTrap(f3,#1),col(#1)),tRange)
diff --git a/src/interp/spaderror.lisp b/src/interp/spaderror.lisp
index 42f65a32..7d65b506 100644
--- a/src/interp/spaderror.lisp
+++ b/src/interp/spaderror.lisp
@@ -1,6 +1,6 @@
;; Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
;; All rights reserved.
-;; Copyright (C) 2007-2008, Gabriel Dos Reis.
+;; Copyright (C) 2007-2011, Gabriel Dos Reis.
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
@@ -43,34 +43,29 @@
;;(defmacro |trappedSpadEval| (form) form) ;;nop for now
-#+:akcl
+#+:gcl
(defun |resetStackLimits| () (system:reset-stack-limits))
-#-:akcl
+#-:gcl
(defun |resetStackLimits| () nil)
-;; failed union branch -- value returned for numeric failure
-(defconstant |$numericFailure| (cons 1 "failed"))
-
(defvar |$oldBreakMode|)
-;; following macro evaluates form returning Union(type-of form, "failed")
-
+;; following macro evaluates form returning Maybe type-of form
+#+:gcl
(defmacro |trapNumericErrors| (form)
`(let ((|$oldBreakMode| |$BreakMode|)
- (|$BreakMode| '|trapNumerics|)
+ (|$BreakMode| '|trapNumerics|))
(val))
- (setq val (catch '|trapNumerics| ,form))
- (if (eq val |$numericFailure|) val
- (cons 0 val))))
+ (catch '|trapNumerics| ,form))
-;;;;;; considering this version for kcl
-;;(defmacro |trapNumericErrors| (form)
-;; `(let ((val))
-;; (setq val (errorset ,form))
-;; (if (NULL val) |$numericFailure| (cons 0 (car val)))))
+#-:gcl
+(defmacro |trapNumericErrors| (form)
+ `(handler-bind ((division-by-zero
+ #'(lambda (c) (declare (ignore c)) |%nothing|)))
+ ,form))
;; the following form embeds around the akcl error handler
-#+:akcl
+#+:gcl
(eval-when
(load eval)
(unembed 'system:universal-error-handler)
@@ -85,7 +80,8 @@
(|systemError| (error-format error-string args)))
((and (eq |$BreakMode| '|trapNumerics|)
(eq type :ERROR))
- (setq |$BreakMode| nil) (throw '|trapNumerics| |$numericFailure|))
+ (setq |$BreakMode| nil)
+ (throw '|trapNumerics| |%nothing|))
((and (eq |$BreakMode| '|trapNumerics|)
(boundp '|$oldBreakMode|)
(setq |$BreakMode| |$oldBreakMode|)