[Openmcl-devel] with-package
Taoufik Dachraoui
dachraoui.taoufik at gmail.com
Sat Jan 12 07:30:24 PST 2013
I am wrote a very simple package system that I am using for all my
developments, I wanted to add
the macro with-package so that I can use a package temporarily and then
revert to previous context
just before using the package.
in all my developments all lisp files are packages and within each file, in
the header of the file, I use some
other packages and I export the symbols that I want them to be visible to
other packages
example:
I have the files match.lisp, syntax.lisp, utils/utils.lisp and
calculus.lisp within the directory <current-directory>
;; file match.lisp
(use utils/utils)
(export '(match))
....
;; file syntax.lisp
(use match)
(export '(syntax))
...
;; file calculus.lisp
(use syntax match utils/utils)
(export '(share))
...
This works fine and I have the possibility to use and unuse a package at
will without dealing with conflicts
to avoid some issues, that I encountered, I imposed a restriction that I
only can un-use the last used package
example:
(use package1)
...
(use package2)
...
(unuse package1) ; this is not possible
This restriction is imposed to avoid that only a subset of some used
package is imported
(after some sequences of use and unuse), and I found the solution to this
cumbersome.
Now, is it good to have a package system that deals with conflicts
automatically
the way I am doing it? I am not sure but I found it easy to implement and
easy to use.
The only issue is with the macro with-package that I can use in situations
where I need a package
in a small section of the program I am writing
Taoufik
On Sat, Jan 12, 2013 at 4:06 PM, Robert P. Goldman <rpgoldman at sift.info>wrote:
> I would really discourage you from doing this, even if you can get it to
> work. Stuffing symbols into a package and then ripping them back out on the
> fly is pretty crude surgery. It makes the correctness of your code depend
> on arbitrary context. ("When I call this, will it cause a symbol clash
> error?").
>
> Am I correct in thinking that all you want to do is save some typing? If
> so, a macro that lets you access symbols without explicitly specifying the
> package, but doesn't have these gross side effects, is probably to be
> preferred.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20130112/66ec4649/attachment.htm>
More information about the Openmcl-devel
mailing list