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

Jim Prewett download at hpc.unm.edu
Fri Feb 10 17:52:20 UTC 2006


Ah-Ha!  It must be something to do with the threads as you say.

I seem to get the same result reguardless of which package I start TBNL 
from.  FWIW, I'm using CMU Common Lisp 19b (19B) on FreeBSD 4.11-STABLE.

I still get the same result reguardless of which package I start TBNL 
from.  My file now looks like this:

(defpackage :mypackage)
(in-package :mypackage)

(tbnl:start-tbnl)

(defun some-func ()
  (cl-who:with-html-output-to-string (*standard-output* nil :prologue nil 
:indent nil)
    (:HTML 
     (:HEAD 
      (:TITLE "foo"))
     (:BODY
      (cl-who:str
       (CL-WHO:ESCAPE-STRING 
        (format () "package: ~A" *package*)))))))
     
(setq tbnl:*dispatch-table*
      (list (tbnl:create-prefix-dispatcher 
             "/foo"
             #'some-func)))

> Why should it display #<MYPACKAGE package>?  *PACKAGE* is a runtime
> concept, it's not a literal constant that's hard-coded into the
> function when you compile it:

Right.  The point of my example was to show that, at runtime, *PACKAGE* 
seems to always be bound to :COMMON-LISP-USER for any function I run 
inside of TBNL.  My cureosity is why does that happen; while I haven't yet 
looked at the CMUCL thread documentation, my guess is that it is related 
to threads.

> The package you see in your example depends on how (from where) you
> started TBNL and how (from where) the thread that handles the request
> is invoked.  

Under CMUCL, I see that the former (where TBNL is started) has no effect.  
My guess is that, for whatever reason, the thread is launched in the
:COMMON-LISP-USER package.

> So, the important part is missing in your example above: When and how
> did you invoke TBNL:START-TBNL?  I bet you did that from CL-USER and
> you will see a different result if you start it from MYPACKAGE.

It doesn't seem to matter. :)  In my original email, I stated that my Lisp 
environment is set up such that I *NEVER* see the CL-USER package which is 
why I found it so strange that *PACKAGE* would ever be set to 
:COMMON-LISP-USER!

> If you're doing something with packages at runtime you should always
> re-bind *PACKAGE* - or in the case of INTERN you should use its second
> argument.

Thats probably the advice I was looking for :)  Sorry for being so dense 
:)

Jim



More information about the Tbnl-devel mailing list