I am experimenting with creating my own set of packages that my own software can use instead of the cl package. This, of course, depends on actually being able to use the common-lisp symbols, just controlling how they're exported.
So I have my base package, called "PRELUDE.BASE", that imports cl, adds some functions and exports most of CL again. The issue comes when I use defun. The following function, defined in "PRELUDE.STRING" does not work as expected:
Code: Select all
(defun join (strings &optional token)
(let ((format (if token
(format nil "~~{~~a~~^~a~~}" token)
"~{~a~}")))
(format nil format strings))),
Code: Select all
(defpackage #:prelude.base
(:nicknames #:base)
(:use #:cl)
(:shadow #:get #:set)
(:export
"&ALLOW-OTHER-KEYS"
"&AUX"
"&BODY"
"&ENVIRONMENT"
"&KEY"
"&OPTIONAL"
"&REST"
"&WHOLE"
#:defun
#:let
#:if
#:nil
#:list
#:first
#:format))
Code: Select all
(defpackage #:prelude.string
(:nicknames #:string #:str)
(:use #:prelude.base)
(:export
#:join))
The reason this does not work is because &OPTIONAL is (apparently) not recognized as CL:&OPTIONAL, so it's interpreted as just a variable name. Changing the above join definition to:
Code: Select all
(defun join (strings cl:&optional token)
(let ((format (if token
(format nil "~~{~~a~~^~a~~}" token)
"~{~a~}")))
(format nil format strings))),
I'm greatly confused by this. When I switch, in slime, to the "PRELUDE.STRING" package and do (symbol-package '&OPTIONAL) it reports the "COMMON-LISP" package. Anyone know what the issue could be?