Reputation: 2132
I define a package
[10]> (defpackage :abc)
#<PACKAGE ABC>
[11]>
I use that package
[15]> (in-package :abc)
#<PACKAGE ABC>
ABC[16]>
How to exit ABC[16] to [17] ?
Thank you~
Upvotes: 4
Views: 811
Reputation: 5030
Strictly speaking you don't use the package with in-package
but you
set the current package. To use a package you've to use use-package
.
Back to your problem, you've defined a new package (without using :cl
so you'll have to use (cl:+ 1 2)
to do an addition) and set it as
the current package. COMMON-LISP-USER
a.k.a. CL-USER
is the
current package when you start your lisp system, thus to have it back
you just have to do (cl:in-package :cl-user)
.
Here is a nice tutorial on packages in Common Lisp. This chapter in PCL is also very good. But the reference is still the CLHS
Upvotes: 6
Reputation: 871
You should get back to the :cl-user
package by (in-package :cl-user)
.
Common Lisp packages are generally a bit confusing for the new comers. I also recommend you to read Erann Gat's tutorial on packages.
As a convention, in the case of a serious (i.e big) program, people tend to make package definitions in a separate file which includes (defpackage :foo ... )
and the real code goes into another one which generally begins with (in-package :foo)
. Then by the help of a system definition facility like ASDF, the file which consists of
package definitions are evaled and loaded before the actual file.
According to my humble view and experience, the easiest way to solve the package mystery is to read actual code developed by experienced lispers after a quick tutorial session.
Upvotes: 1