[Lispweb] [tbnl-devel] Re: tbnl: what package?

Edi Weitz edi at agharta.de
Fri Feb 10 09:09:00 CST 2006

On Fri, 10 Feb 2006 06:25:45 -0700 (MST), Jim Prewett <download at hpc.unm.edu> wrote:

> I'm guessing this is what I just ran into and the answer is your new
> function names and symbols will be interned in :CL-USER :) I'd love
> to know how to change that, but haven't bothered to dig yet.  (in my
> case, :CL-USER would be my second choice after one of my own
> packages)
> In my case, I had code that uses the multi-method dispatch mechanism
> to display the right page (I'm not yet sure if thats a good idea :)
> something like this:
> (defmethod display-page (page-name (eql 'login-page))
>       ... )
> To convert the text strings given by the user into the right symbol
> (so this dispatch mecnhanism can work), I must intern them in the
> :CL-USER package.
> This did take me a while to figure out and *I* couldn't find it in
> the documentation anywhere.  (I guess, maybe, it should have been
> obvious, but I still consider myself mostly a Lisp newbie).  I
> believe my CMUCL Lisp starts with a core file causing it to start in
> :Jims-PackageA, then I've been loading a file (that causes TBNL and
> all that good stuff to be loaded) and immediately switching to
> :Jims-PackageB, so it was really confusing to be using the :CL-USER
> package at all. :)

Hmm.  It /seems/ to me that both of you are rather talking about
general problems with packages and not about TBNL in particular.  TBNL
itself never interns symbols except when it creates keywords, and in
this case the package is clearly defined.

You should always create your own package to work in if you write
code, don't use CL-USER.  See test.lisp in TBNL for an example.

If your code looks like this

  (defmethod display-page (page-name (eql 'login-page))
        ... )

then LOGIN-PAGE will be a symbol accessible in the package you're in,
i.e. the package of the file the method is defined in (assuming you
used LOAD to load the file).  In 99.9% of all cases this should be the
package you find in the very first line starting with IN-PACKAGE.  If
you don't have such a line there - see above... :)

Sorry if that sounds patronizing, maybe I'm again missing the point.


More information about the lispweb mailing list