summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.lisp10
-rw-r--r--print.lisp6
-rw-r--r--str.lisp2
-rw-r--r--utils.asd2
-rw-r--r--utils.lisp11
5 files changed, 18 insertions, 13 deletions
diff --git a/package.lisp b/package.lisp
index f4158be..81821dd 100644
--- a/package.lisp
+++ b/package.lisp
@@ -1,10 +1,10 @@
-(defpackage #:alien
- (:use #:cl #:sb-alien)
- (:export #:call))
+(defpackage #:utils
+ (:use #:cl)
+ (:export #:with-package))
-(defpackage #:print
+(defpackage #:alien
(:use #:cl)
- (:export #:table))
+ (:export #:call))
(defpackage #:queue
(:use #:cl)
diff --git a/print.lisp b/print.lisp
deleted file mode 100644
index 1ea7932..0000000
--- a/print.lisp
+++ /dev/null
@@ -1,6 +0,0 @@
-(in-package #:print)
-
-(defun table (tbl)
- (maphash (lambda (k v)
- (format t "~a : ~a~&" k v))
- tbl))
diff --git a/str.lisp b/str.lisp
index a8b2a7f..5116be4 100644
--- a/str.lisp
+++ b/str.lisp
@@ -1,6 +1,6 @@
(in-package #:str)
-(declaim (optimize (speed 3) (safety 0)))
+(declaim (optimize (speed 3) (safety 1)))
(declaim (ftype (function ((or pathname string)) (values string &optional)) read-file))
(defun read-file (path)
diff --git a/utils.asd b/utils.asd
index bd97c0c..7a12042 100644
--- a/utils.asd
+++ b/utils.asd
@@ -2,7 +2,7 @@
:serial t
:components
((:file "package")
+ (:file "utils")
(:file "queue")
(:file "alien")
- (:file "print")
(:file "str")))
diff --git a/utils.lisp b/utils.lisp
new file mode 100644
index 0000000..d0f61d5
--- /dev/null
+++ b/utils.lisp
@@ -0,0 +1,11 @@
+(in-package #:utils)
+
+(defmacro with-package (pkg-sym &body body)
+ (let ((pkg-name (symbol-name pkg-sym)))
+ (unless (find-package pkg-name)
+ (make-package pkg-name))
+ (let ((body-as-string (format nil "(cl:progn ~{~s~&~})" body))
+ (body-as-form))
+ (let ((*package* (find-package pkg-name)))
+ (setq body-as-form (read-from-string body-as-string)))
+ body-as-form)))