From: Drew Krause
Subject: getting fancy with packages
Date: 
Message-ID: <A5Ted.7577$ta5.568@newsread3.news.atl.earthlink.net>
OK, I need help with packages. I usually run Lisp in the package "cm" 
(Common Music). I've written, though, some real nifty Screamer functions 
that work only when I first enter "(in-package :screamer-user)" Note: 
they do not work when I enter simply (use-package 'screamer), nor do 
they work if I simply load the file containing these functions and the 
'in-package' declaration from cm -- I'm guessing that I'm returned to 
the cm environment & therefore out of luck.

It appears that cm and screamer do not work well together, as I get lots 
of errors if I try to load functions from one when I'm in the other. 
What I would really, ideally like to do is:

1. Work entirely in cm;
2. Keep my nifty Screamer functions sitting in a file;
3. Be able to call the Screamer functions from cm somehow and have the 
results returned back to my cm environment.

I hope there's a way to do this, but the CLTL guide is a bit *too* 
informative for my  level of expertise. The alternative (of cutting and 
pasting data across environments) is none too appetizing.

Oh Lisp wizards -- please help me!

Thanks,
Drew Krause

From: Harald Hanche-Olsen
Subject: Re: getting fancy with packages
Date: 
Message-ID: <pco7jpf6gzm.fsf@shuttle.math.ntnu.no>
+ Drew Krause <········@mindspring.com>:

| OK, I need help with packages. I usually run Lisp in the package "cm"
| (Common Music). I've written, though, some real nifty Screamer
| functions that work only when I first enter "(in-package
| :screamer-user)" Note: they do not work when I enter simply
| (use-package 'screamer), nor do they work if I simply load the file
| containing these functions and the 'in-package' declaration from cm --
| I'm guessing that I'm returned to the cm environment & therefore out
| of luck.

First, "do not work" is too vague a description.  We have to guess
what you mean by that.  We need to know

- what did you do?
- what did you expect?
- what happened instead?

But anyway, I will make a guess at what happened and make some
recommendations based on that guess.  My guess is that you wanted to
call a function named FOO (substitute the real name here) in the
screamer-user package.  Maybe you entered (foo ...) at the prompt,
expected the FOO function to be called, but instead got something
about "the function FOO is undefined".  Am I right?

If so, first you should know that it isn't the function FOO that is in
the screamer-user package; it is the symbol FOO, which again names the
function.  You need to say screamer-user:foo to access the symbol (or
maybe just screamer:foo, depending on how the package is set up).  So
you call should have been (screamer:foo ...).  Maybe this will result
in a complaint that FOO is not exported from the SCREAMER package.  If
so, the debugger will probably offer you the option of using it
anyway.  Fix later, by arranging for the symbol to be exported, or by
calling it screamer::foo instead.  (But any use of :: is a signal that
you are using a symbol that the package designer did not intend for
you to use, so you're threading on thin ice.)

Another possibility is that some of the functions you are calling are
interning symbols in the current package, when they should really be
interned in the screamer package instead.  If so, this is most likely
a design fault.  Most functions don't need to do this sort of things,
and when they do, the programmer needs to be very careful about doing
things in the right package.  But without any further information from
you, we can't know if this is your problem.

BTW, have you looked at Peter Seibels book manuscript?

  http://www.gigamonkeys.com/book/

Try Chapter 17, it might have what you need at a level you can handle.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Christophe Turle
Subject: Re: getting fancy with packages
Date: 
Message-ID: <417c0908$0$24459$636a15ce@news.free.fr>
"Drew Krause" <········@mindspring.com> a �crit dans le message de news: 
··················@newsread3.news.atl.earthlink.net...
> OK, I need help with packages. I usually run Lisp in the package "cm" 
> (Common Music). I've written, though, some real nifty Screamer functions 
> that work only when I first enter "(in-package :screamer-user)" Note: they 
> do not work when I enter simply (use-package 'screamer), nor do they work 
> if I simply load the file containing these functions and the 'in-package' 
> declaration from cm -- I'm guessing that I'm returned to the cm 
> environment & therefore out of luck.
>
> It appears that cm and screamer do not work well together, as I get lots 
> of errors if I try to load functions from one when I'm in the other. What 
> I would really, ideally like to do is:

I don't know if i understand well your problem, but here a try :


; screamer load stuff

> 1. Work entirely in cm;

 ; don't use screamer package in your (defpackage :cm ...)

(in-package :cm)

> 2. Keep my nifty Screamer functions sitting in a file;

ok. just load them.

> 3. Be able to call the Screamer functions from cm somehow and have the 
> results returned back to my cm environment.

(screamer:my-screamer-fct my-cm-paramter)


-- 
___________________________________________________________
Christophe Turle.
sava preview http://perso.wanadoo.fr/turle/lisp/sava.html
(format nil ···@~a.~a" 'c.turle 'wanadoo 'fr) 
From: Drew Krause
Subject: Re: getting fancy with packages
Date: 
Message-ID: <PXffd.8497$ta5.1318@newsread3.news.atl.earthlink.net>
Thanks to all who replied. I experimented & cobbled together a solution. 
My screamer function file now looks like:

(in-package: screamer-user)
[bunch of screamer functions]
; then, at the end of the file ....
(in-package: cm)

Now I load "screamerfuncfile.lisp" and call a screamer function with

(screamer-user::myscreamfunc blah blah)

in the cm environment. Seems to work!

Thanks again,
Drew

Ingvar wrote:

>Drew Krause <········@mindspring.com> writes:
>
>  
>
>>OK, I need help with packages. I usually run Lisp in the package "cm"
>>(Common Music). I've written, though, some real nifty Screamer
>>functions that work only when I first enter "(in-package
>>:screamer-user)" Note: they do not work when I enter simply
>>(use-package 'screamer), nor do they work if I simply load the file
>>containing these functions and the 'in-package' declaration from cm --
>>I'm guessing that I'm returned to the cm environment & therefore out
>>of luck.
>>
>>It appears that cm and screamer do not work well together, as I get
>>lots of errors if I try to load functions from one when I'm in the
>>other. What I would really, ideally like to do is:
>>
>>1. Work entirely in cm;
>>2. Keep my nifty Screamer functions sitting in a file;
>>3. Be able to call the Screamer functions from cm somehow and have the
>>results returned back to my cm environment.
>>
>>I hope there's a way to do this, but the CLTL guide is a bit *too*
>>informative for my  level of expertise. The alternative (of cutting
>>and pasting data across environments) is none too appetizing.
>>    
>>
>
>Most probably, what is needed is a call to USE-PACKAGE somewhere.
>Personally, I prefer prefixing all symbols taht are not package-local
>with the name of the package they're exported from (and tr4y to stay
>away from using unexported symbols).
>
>Give:
>  (use-package :screamer-user)
>a try and see if that works?
>
>//ingvar
>  
>
From: Pierpaolo BERNARDI
Subject: Re: getting fancy with packages
Date: 
Message-ID: <opsgq1m4nmxbm8ci@ppp-112-195.98-62.inwind.it>
On Mon, 25 Oct 2004 23:25:35 GMT, Drew Krause <········@mindspring.com> wrote:

> Thanks to all who replied. I experimented & cobbled together a solution.
> My screamer function file now looks like:

Actually, you needed to use the macro DEFINE-SCREAMER-PACKAGE.

This macro creates a package with the standard symbols DEFUN,
MULTIPLE-VALUE-BIND, and Y-OR-NO-P shadowed with screamer specific
versions.

Try changing the form which creates the CM package to use
DEFINE-SCREAMER-PACKAGE instead, or modify this form to make
the same shadowing imports that DEF-SCREAMER-PACK makes,
or add an appropriate SHADOWING-IMPORT after the CM package
creation and before any other form.

P.