Lisp HUG Maillist Archive

in-package oddity

Hello all

I was recently given a file which contained, near the top  something like

(cl:in-package :foo)

[where :foo does actually denote a package]

and I'm not being placed in the package named
"FOO".

removing the cl prefix from in-package gives the expected behavior.
I've made a quicktime vid here:
http://www.cs.rpi.edu/~tayloj/lispworks.mov

Is this a bug?


-- 
=====================
Joshua Taylor
tayloj@rpi.edu

"A lot of good things went down one time,
     back in the goodle days."
               John Hartford


AW: in-package oddity

 

> -----Ursprüngliche Nachricht-----
> Von: owner-lisp-hug@lispworks.com 
> [mailto:owner-lisp-hug@lispworks.com] Im Auftrag von Taylor, Joshua
> Gesendet: Samstag, 17. Februar 2007 22:09
> An: Lispworks HUG
> Betreff: in-package oddity
> 
> 
> Hello all
> 
> I was recently given a file which contained, near the top  
> something like
> 
> (cl:in-package :foo)
> 
> [where :foo does actually denote a package]
> 
> and I'm not being placed in the package named "FOO".
> 
> removing the cl prefix from in-package gives the expected behavior.
> I've made a quicktime vid here:
> http://www.cs.rpi.edu/~tayloj/lispworks.mov
> 
> Is this a bug?
> ...

Hi Joshua,

in LWW 5.0.1 following happens:

CL-USER 19 > (cl:in-package :capi)
#<The CAPI package, 3623/4096 internal, 665/1024 external>

CAPI 20 > (cl:in-package :user)
#<The COMMON-LISP-USER package, 465/512 internal, 0/4 external>

So I guess it is a bug.

Andreas

P.S.

CL-USER 18 > (describe 'cl:in-package)

IN-PACKAGE is a SYMBOL
NAME          "IN-PACKAGE"
VALUE         #<unbound value>
FUNCTION      #<Function SYSTEM::IN-PACKAGE-MACRO 202B685A>
PLIST         (EDITOR::SECTION EDITOR::SECTION-IN-PACKAGE)
PACKAGE       #<The COMMON-LISP package, 3/4 internal, 978/1024 external>



Re: in-package oddity

On Sat, 17 Feb 2007 16:09:01 -0500, "Taylor, Joshua" <tayloj@rpi.edu> wrote:

> I was recently given a file which contained, near the top something
> like
>
> (cl:in-package :foo)
>
> [where :foo does actually denote a package]
>
> and I'm not being placed in the package named
> "FOO".
>
> removing the cl prefix from in-package gives the expected behavior.
> I've made a quicktime vid here:
> http://www.cs.rpi.edu/~tayloj/lispworks.mov

What you're seeing at the bottom (in the modeline) is not in which
package you're "placed" (what would that mean anyway?), but which
package the editor thinks your Lisp file is in (or more precise: which
package the part of the Lisp file where point is is in).  It seems to
use some kind of heuristics where it walks backwards beginning from
point and looks for a form that starts at column 0 and begins with
"(in-package ".

Try this: In the listener, create packages :FOO and :BAR with
DEFPACKAGE.  Now create a file foo.lisp which looks like this:

-------------------> start of foo.lisp <-------------------

(in-package :foo)

(in-package :bar)

  (in-package :foo)

(cl:in-package :foo)

(in-package :cl-user)

--------------------> end of foo.lisp <--------------------

(Note the indentation of the third form.)

Now move the cursor up and down between these forms and press the
Return key from time to time.  Note how the modeline changes depending
on where you are.  Also note that the third and fourth form don't seem
to have any effect.

> Is this a bug?

Depends on your POV, I'd say.  I think it is clear that you have to
use some kind of heuristics.  One could argue that the heuristics the
LW editor uses are a bit weak.  FWIW, SLIME can cope with the fourth
form above, but it fails to recognize the third form as well.  Go
figure...

HTH,
Edi.


Updated at: 2020-12-10 08:46 UTC