[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Packages
- To: info-mcl@ministry.cambridge.apple.com
- Subject: Re: Packages
- From: halvers@procyon.crd.ge.com (Pete Halverson)
- Date: Wed, 6 Oct 1993 15:00:17 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: GE Corp. Research & Development, Schenectady, NY
- References: <Ygg_oxa00iUzMCPG4w@andrew.cmu.edu>
- Reply-to: halverson@crd.ge.com (Pete Halverson)
- Sender: usenet@crdnns.crd.ge.com (USENET News System)
- Summary: split'em
In article <Ygg_oxa00iUzMCPG4w@andrew.cmu.edu> robby+@CMU.EDU (Robert Bruce Findler) writes:
>I am a little confused on how *package* is handled in MCL. It seems like
>each window has a package associated with it and when that window is
>frontmost *package* is bound to the window's package. However, when I
>have this in a fred-window:
>
>(in-package "CL-USER")
>(defpackage "CLOADER" (:use "COMMON-LISP")
> (:export *file-table* *root*
> *verbose* initialize-file-table))
>(in-package "CLOADER")
>
>and I evaluate the buffer, the package associated with the window stays
>as CL-USER.
Right. Although the loader and compiler can switch *PACKAGE* values
whenever they read an IN-PACKAGE form, the editor probably just uses the
first IN-PACKAGE it sees; subsequent ones don't count. I have yet to see a
Lisp editor that recognizes multiple IN-PACKAGE forms in a buffer and bases
the current buffer package on the current cursor position.
> When I have this in a fred-window:
>
>(defpackage "CLOADER" (:use "COMMON-LISP")
> (:export *file-table* *root*
> *verbose* initialize-file-table))
>(in-package "CLOADER")
>
>and I evaluate the buffer, I get an error. What I want to happen is that
>the window gets the package "CLOADER" associated with it. How do I do
>this?
Hard to say what the problem is without knowing the particular error you're
encountering and the dynamic context it's in (has the DEFPACKAGE been
evaluated yet?). In general though, because of this and similar problems,
Steele (cltl2 pp. 278) recommends separating the code that defines your
package from code that uses it, e.g.
;; package.lisp
(in-package "CL-USER")
(defpackage "CLOADER"
(:use "COMMON-LISP")
(:export *file-table* *root* *verbose* initialize-file-table))
;; module-1.lisp
(in-package "CLOADER")
(defvar *file-table* ...
and use PROVIDE/REQUIRE or one of the gazillion DEFSYSTEM's floating about
to make sure that "package" gets loaded before you edit/load/compile
"module-1". It's a stylistic thing; though you might think it overkill for
a single module system, it will make things much easier as your system
grows (as they always do :-)
Pete Halverson INET: halverson@crd.ge.com
GE Corporate R&D Center UUCP: uunet!crd.ge.com!halverson
Schenectady, NY
- References:
- Packages
- From: Robert Bruce Findler <robby+@CMU.EDU>