chiark
/
gitweb
/
~mdw
/
lisp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
base: compile-time-defun should define in the interpreter.
[lisp]
/
mdw-base.lisp
diff --git
a/mdw-base.lisp
b/mdw-base.lisp
index 37a30684330953cea4daaa00702f2fb116be4e32..73f85e73d95f0bfd84f9371d6d2c0783ab72c888 100644
(file)
--- a/
mdw-base.lisp
+++ b/
mdw-base.lisp
@@
-28,12
+28,13
@@
(defpackage #:mdw.base
(:use #:common-lisp)
(defpackage #:mdw.base
(:use #:common-lisp)
- (:export #:compile-time-defun
+ (:export #:unsigned-fixnum
+ #:compile-time-defun
#:show
#:stringify #:mappend #:listify #:fix-pair #:pairify #:parse-body
#:whitespace-char-p
#:slot-uninitialized
#:show
#:stringify #:mappend #:listify #:fix-pair #:pairify #:parse-body
#:whitespace-char-p
#:slot-uninitialized
- #:nlet #:while #:case2 #:ecase2
+ #:nlet #:while #:
until #:
case2 #:ecase2
#:with-gensyms #:let*/gensyms #:with-places
#:locp #:locf #:ref #:with-locatives
#:update-place #:update-place-after
#:with-gensyms #:let*/gensyms #:with-places
#:locp #:locf #:ref #:with-locatives
#:update-place #:update-place-after
@@
-43,13
+44,20
@@
(defpackage #:mdw.base
(in-package #:mdw.base)
(in-package #:mdw.base)
+;;;--------------------------------------------------------------------------
+;;; Useful types.
+
+(deftype unsigned-fixnum ()
+ "Unsigned fixnums; useful as array indices and suchlike."
+ `(mod ,most-positive-fixnum))
+
;;;--------------------------------------------------------------------------
;;; Some simple macros to get things going.
(defmacro compile-time-defun (name args &body body)
"Define a function which can be used by macros during the compilation
process."
;;;--------------------------------------------------------------------------
;;; Some simple macros to get things going.
(defmacro compile-time-defun (name args &body body)
"Define a function which can be used by macros during the compilation
process."
- `(eval-when (:compile-toplevel :load-toplevel)
+ `(eval-when (:compile-toplevel :load-toplevel
:execute
)
(defun ,name ,args ,@body)))
(defmacro show (x)
(defun ,name ,args ,@body)))
(defmacro show (x)
@@
-111,7
+119,9
@@
(compile-time-defun pairify (x &optional (y nil defaultp))
(defun whitespace-char-p (ch)
"Return whether CH is a whitespace character or not."
(case ch
(defun whitespace-char-p (ch)
"Return whether CH is a whitespace character or not."
(case ch
- ((#\space #\tab #\newline #\return #\vt #\formfeed) t)
+ ((#\space #\tab #\newline #\return #\vt
+ #+cmu #\formfeed
+ #+clisp #\page) t)
(t nil)))
(declaim (ftype (function nil ()) slot-unitialized))
(t nil)))
(declaim (ftype (function nil ()) slot-unitialized))
@@
-189,9
+199,11
@@
(defmacro nlet (name binds &body body)
(defmacro while (cond &body body)
"If COND is false, evaluate to nil; otherwise evaluate BODY and try again."
(defmacro while (cond &body body)
"If COND is false, evaluate to nil; otherwise evaluate BODY and try again."
- `(loop
- (unless ,cond (return))
- ,@body))
+ `(loop (unless ,cond (return)) (progn ,@body)))
+
+(defmacro until (cond &body body)
+ "If COND is true, evaluate to nil; otherwise evaluate BODY and try again."
+ `(loop (when ,cond (return)) (progn ,@body)))
(compile-time-defun do-case2-like (kind vform clauses)
"Helper function for `case2' and `ecase2'."
(compile-time-defun do-case2-like (kind vform clauses)
"Helper function for `case2' and `ecase2'."