advice on using packages



>>>>> "Barton" == Barton Willis <willisb at unk.edu> writes:

    Barton> I was thinking about how I might use the package system in linalg.
    Barton> So, I tried the experiment:

    MAXIMA> (defpackage :my (:use :common-lisp :maxima)
    Barton>      (:import-from :maxima #:add :maxima :mplus :maxima :simp))

    MY> (add '$a '$b);
    Barton> ((MPLUS SIMP) $A $B)

    Barton> (Q1) Is all this :import stuff really needed?

I think it would work without the :import-from, since you're :use'ing
:maxima already.  That is, no package qualifiers needed to refer to a
symbol in the maxima package.


    Barton> (Q2) Switching back to the 'maxima' package seems
    Barton> like it will cause trouble:

    MY> (setf q (add '$a '$b));
    Barton> ((MPLUS SIMP) $A $B)
    MY> (in-package :maxima);
    Barton> #<"MAXIMA" package>
    MAXIMA> q
    Barton> Maxima encountered a Lisp error:
    Barton>  Error in EVAL [or a callee]: The variable Q is unbound.

    MAXIMA> my::q
    Barton> ((MPLUS SIMP) MY::$A MY::$B)

    Barton> How could this be done? (A general scheme to change
    Barton> my::<junk>  --> <junk>.)

You would have to programmatically import my::q to maxima.  But I
think this is not the typical way to use the MY package.

I think you would typically be in the maxima package and access stuff
from your MY package.  Of course, you'd have to use package qualifiers
(my::foo) to access them, unless you tell maxima to :use your package.
It would be a bit unusual to have maxima :use MY, though, but not
always.

    Barton> (Q3) Other advice -- perhaps a pointer to a good
    Barton> tutorial on packages in CL?

I believe Practical Common Lisp (available on the web) has a good
section on packages.

Ray