[Openmcl-devel] with-package

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Sat Jan 12 05:55:58 PST 2013


Current package when you call with-package

? *package*
#<Package "COMMON-LISP-USER">

;; The curent package is COMMON-LISP-USER

? (with-package (calculus) (share '(fn x (+ x 1))))
;;; (share '(fn x (+ x 1))) must be evaluated (use calculus), where share
is imported from the package calculus

I tried the following to show the issue:

? (unintern 'share)
T
? (use calculus)
NIL
? (values (find-symbol "SHARE") (symbol-package 'share))
SHARE
#<Package "/Users/mazeboard/workspace/ccl/CALCULUS.LISP">
? (share '(fn x (+ x 1)))
... ; result of the function share imported from calculus
? (unuse calculus)
NIL
? (values (find-symbol "SHARE") (symbol-package 'share))
SHARE
#<Package "COMMON-LISP-USER">  ;;; after unuse calculus SHARE is not from
calculus anymore
? (progn (use calculus) (values (find-symbol "SHARE") (symbol-package
'share)))
SHARE
NIL
?

As you can see in the last expression (progn) even though we use calculus
the symbol SHARE is
not visible

Thank you for the help

Taoufik




On Sat, Jan 12, 2013 at 2:36 PM, Pascal J. Bourguignon <
pjb at informatimago.com> wrote:

> Taoufik Dachraoui <dachraoui.taoufik at gmail.com> writes:
>
> > Hi
> >
> > I am trying to define a macro as follows:
> >
> > (defmacro with-package ((&rest names) &body body)
> >   `(progn
> >      (use , at names)
> >      , at body
> >      (unuse ,@(reverse names))))
> >
> > The issue is that the body may use symbols defined in one of
> > the names (packages) and not in the current package
>
> "Current" WHEN?
>
>
>
> > How to do this? I tried with eval-when but I do not know how to use
> > it correctly
>
> What are the situations available to eval-WHEN?
>
>
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
> A bad day in () is better than a good day in {}.
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20130112/2d145657/attachment.htm>


More information about the Openmcl-devel mailing list