From: Arthur Gold
Subject: Package spread among multiple source files
Date: 
Message-ID: <gN%Jb.50922$xU1.7818@fe1.texas.rr.com>
As a newbie suddenly doing something a little more substantial (with 
great thanks to comp.lang.lisp), I have a (dumb) newbie question:

What magic (portable?) incantations do I need to have a package span 
multiple source files? Whatever I've tried so far has only further 
confused me.

Could someone point me to a sample where this is done? Or, if 
appropriate, point me to the FM to R?

Many thanks,
--ag

-- 
Artie Gold -- Austin, Texas

From: Thomas F. Burdick
Subject: Re: Package spread among multiple source files
Date: 
Message-ID: <xcvd69zmkcu.fsf@famine.OCF.Berkeley.EDU>
Arthur Gold <·········@austin.rr.com> writes:

> As a newbie suddenly doing something a little more substantial (with 
> great thanks to comp.lang.lisp), I have a (dumb) newbie question:
> 
> What magic (portable?) incantations do I need to have a package span 
> multiple source files? Whatever I've tried so far has only further 
> confused me.

There's no magic or incantations, of course, but sometimes you just
need a paint-by-numbers template before something clicks :-). What you
need to do is load the defpackage form that defines the package.
Then, at the top of each file, put (in-package :foo).  EG:

foo-package.lisp:
  (defpackage :foo
    (:use :common-lisp)
    (:export #:foo #:bar #:baz))

foo-a.lisp:
  (in-package :foo)
  ;; ...

foo-b.lisp:
  (in-package :foo)
  ;; ...

I can now do the following:

  (load "foo-package")
  (load "foo-a")
  (load "foo-b")

or even:

foo.asd:
  (asdf:defsystem :foo
    :name "The Foo system"
    :components
    ((:file "foo-package")
     (:file "foo-a" :depends-on ("foo-package"))
     (:file "foo-b" :depends-on ("foo-package"))))

and then:

  (require :asdf)
  (asdf:oos 'asdf:load-op :foo)

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Christopher C. Stacy
Subject: Re: Package spread among multiple source files
Date: 
Message-ID: <u65frc94z.fsf@news.dtpq.com>
>>>>> On Sun, 04 Jan 2004 21:42:36 GMT, Arthur Gold ("Arthur") writes:
 Arthur> What magic (portable?) incantations do I need
 Arthur> to have a package span multiple source files?

Packages are not associated with files.
You simply invoke the macro IN-PACKAGE at the top of 
your file to set the current package for the remainder 
of the file.  (You could even change it back and forth
in the same file, if you want, but that would be confusing.)

See CLHS 11.1.1 Introduction to Packages
From: Arthur Gold
Subject: Re: Package spread among multiple source files
Date: 
Message-ID: <Qj6Kb.56797$xU1.20083@fe1.texas.rr.com>
Christopher C. Stacy wrote:
>>>>>>On Sun, 04 Jan 2004 21:42:36 GMT, Arthur Gold ("Arthur") writes:
> 
>  Arthur> What magic (portable?) incantations do I need
>  Arthur> to have a package span multiple source files?
> 
> Packages are not associated with files.
> You simply invoke the macro IN-PACKAGE at the top of 
> your file to set the current package for the remainder 
> of the file.  (You could even change it back and forth
> in the same file, if you want, but that would be confusing.)
> 
> See CLHS 11.1.1 Introduction to Packages

Gotcha. Thanks to you both!
--ag