Commit 577cfb62 authored by Liam Healy's avatar Liam Healy

Define #'set-reader and do not change *read-default-float-format* on loading

In order to avoid potential conflict with other programs,
*read-default-float-format* is not set. Instead, a new function
#'set-reader will make the Antik reader macros active in the listener
and set *read-default-float-format*.
parent b585d06f
;; Define package and reader for Antik
;; Liam Healy 2010-12-24 09:12:15EST package.lisp
;; Time-stamp: <2015-01-03 18:01:12EST package.lisp>
;; Time-stamp: <2015-04-05 22:34:43EDT package.lisp>
;; Copyright 2011, 2015 Liam M. Healy
;; Copyright 2010, 2011, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -20,10 +20,6 @@
(in-package :cl-user)
(eval-when (:compile-toplevel :load-toplevel :execute)
(setf *read-default-float-format* 'double-float)
#+allegro (tpl:setq-default *read-default-float-format* 'double-float))
(defpackage #:antik
;; (:nicknames)
(:shadow #:+ #:- #:* #:/
......
;; Define a new readtable
;; Liam Healy 2014-09-28 22:27:28EDT readtable.lisp
;; Time-stamp: <2014-11-27 16:32:40EST readtable.lisp>
;; Time-stamp: <2015-04-05 22:40:06EDT readtable.lisp>
;; Copyright 2014 Liam M. Healy
;; Copyright 2014, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -19,8 +19,15 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :antik)
(export 'antik)
(export 'set-reader)
(named-readtables:defreadtable :antik
(:merge :standard)
(:macro-char #\# :dispatch))
(defun set-reader (&optional (readtable t) (default-float 'double-float))
"If readtable is true, set the reader to enable the three Antik reader macros #_ (physical dimension quantity), #d (date/time), #m (grid). Set the reader to interpret float literals without an exponent marker to be the type specified. If nil, leave as-is."
(named-readtables:in-readtable :antik)
(when default-float
(setf *read-default-float-format* default-float)
#+allegro (tpl:setq-default *read-default-float-format* default-float)))
;; Define physical dimensions and units of measure and systems of units.
;; Liam Healy Wed Feb 27 2002 - 13:18
;; Time-stamp: <2013-09-21 17:10:40EDT units.lisp>
;; Time-stamp: <2015-04-06 22:49:09EDT units.lisp>
;; Copyright 2011, 2013 Liam M. Healy
;; Copyright 2011, 2013, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -522,7 +522,7 @@
(setf (dimension unit)
;; if dimension is given, use it; otherwise, derive from expression
(if dimension (parse-unit-sexp dimension) derived-dim)
(siconversion unit) (or conversion 1)
(siconversion unit) (if conversion (rationalize conversion) 1)
(synonyms unit) (pushnew (unit-remove-illegal-chars unit) synonyms)
(print-name unit) print-name
(canonical-name unit) unit)
......
;; Tests of physical quantities
;; Liam Healy 2011-01-09 17:38:41EST tests.lisp
;; Time-stamp: <2014-11-27 17:31:37EST physical-quantities.lisp>
;; Time-stamp: <2015-04-13 22:59:07EDT physical-quantities.lisp>
;; Copyright 2011, 2013 Liam M. Healy
;; Copyright 2011, 2013, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -57,18 +57,18 @@
(lisp-unit:assert-error 'simple-error (antik:+ #_1_m #_1_s))
(lisp-unit:assert-numerical-equal #_0.5_m/s (/ #_1_m #_2_s))
(lisp-unit:assert-numerical-equal #_6.0_m^2 (* #_3_m #_2_m))
(lisp-unit:assert-numerical-equal #_0.3048_m #_1_foot)
(lisp-unit:assert-numerical-equal #_0.45359237_kg #_1_pound)
(lisp-unit:assert-numerical-equal #_0.3048_m #_1.0_foot)
(lisp-unit:assert-numerical-equal #_0.45359237_kg #_1.0_pound)
(lisp-unit:assert-numerical-equal #_3600_s #_1_hour))
(lisp-unit:define-test system-of-units
(lisp-unit::assert-numerical-equal
10.0d0
(with-system-of-units (t degree) (pqval #_10_degrees)))
(with-system-of-units (t degree) (pqval #_10.0d0_degrees)))
(lisp-unit::assert-numerical-equal
0.3048d0
(antik::pq-magnitude
(with-system-of-units (english) (make-pq 1 'length))))
(with-system-of-units (english) (make-pq 1.0d0 'length))))
(lisp-unit::assert-numerical-equal
100000.0d0
(with-system-of-units (cgs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment