From: Jeff M.
Subject: Simple export?
Date: 
Message-ID: <1101624749.864257.300870@z14g2000cwz.googlegroups.com>
Is there a simple method of exporting all the symbols in an entire
file? Simply put, I have a file with quite a few constants defined, and
I'd rather not have a giant (export '(...)) list of symbols. I'd be
just as happy with a method of exporting all symbols in a package,
even.

Thanks for any advice.

Jeff M.

From: Chris Capel
Subject: Re: Simple export?
Date: 
Message-ID: <10qiu16euj9f625@corp.supernews.com>
Jeff M. wrote:

> Is there a simple method of exporting all the symbols in an entire
> file? Simply put, I have a file with quite a few constants defined, and
> I'd rather not have a giant (export '(...)) list of symbols. I'd be
> just as happy with a method of exporting all symbols in a package,
> even.
> 
> Thanks for any advice.

What I did in a similar situation is define a macro that does what you want
+ exports the symbol. For instance,

(defmacro defconstant&export (&rest args)
  `(progn
     (defconstant ,@args)
     (export ,(first args))))

Now, I'm not sure what sort of eval-when form you need in that--you might
want to experiment, but it worked for me without any eval-when, IIRC, which
I might not.

Chris Capel
From: JP Massar
Subject: Re: Simple export?
Date: 
Message-ID: <jk8kq0150sbpjsf2bjk8utl9brin344hg2@4ax.com>
On 27 Nov 2004 22:52:29 -0800, "Jeff M." <·······@gmail.com> wrote:
 I'd be
>just as happy with a method of exporting all symbols in a package,
>even.
>
 
DO-SYMBOLS loops through all the symbols in a package.
You could just call EXPORT on each symbol
(although if your package is already used by some package this
could trigger a package error)
From: Chris Capel
Subject: Re: Simple export?
Date: 
Message-ID: <10qk9i4doi9n496@corp.supernews.com>
JP Massar wrote:

> On 27 Nov 2004 22:52:29 -0800, "Jeff M." <·······@gmail.com> wrote:
>  I'd be
>>just as happy with a method of exporting all symbols in a package,
>>even.
>>
>  
> DO-SYMBOLS loops through all the symbols in a package.
> You could just call EXPORT on each symbol
> (although if your package is already used by some package this
> could trigger a package error)

Not only that, but do-symbols includes *every* symbol that was read when the
package was loaded, including things like local variables and parameters
and things down in the guts of macros. It's extremely unlikely that you'll
want to export all of these, so unless the package itself contains nothing
but symbols you want to export, do-symbols isn't a good idea.

Now, you can go ahead and define all your constants in a different package,
and then import the symbols from that package into your main package using
do-symbols, and then export them from your main package as well.

Chris Capel
From: Peter Seibel
Subject: Re: Simple export?
Date: 
Message-ID: <m3pt1wa4h0.fsf@javamonkey.com>
Chris Capel <······@iba.nktech.net> writes:

> JP Massar wrote:
>
>> On 27 Nov 2004 22:52:29 -0800, "Jeff M." <·······@gmail.com> wrote:
>>  I'd be
>>>just as happy with a method of exporting all symbols in a package,
>>>even.
>>>
>>  
>> DO-SYMBOLS loops through all the symbols in a package. You could
>> just call EXPORT on each symbol (although if your package is
>> already used by some package this could trigger a package error)
>
> Not only that, but do-symbols includes *every* symbol that was read
> when the package was loaded, including things like local variables
> and parameters and things down in the guts of macros. It's extremely
> unlikely that you'll want to export all of these, so unless the
> package itself contains nothing but symbols you want to export,
> do-symbols isn't a good idea.
>
> Now, you can go ahead and define all your constants in a different
> package, and then import the symbols from that package into your
> main package using do-symbols, and then export them from your main
> package as well.

Or you could only export symbols that are BOUNDP and CONSTANTP.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Sam Steingold
Subject: Re: Simple export?
Date: 
Message-ID: <uis7o4jyj.fsf@gnu.org>
> * Jeff M. <·······@tznvy.pbz> [2004-11-27 22:52:29 -0800]:
>
> Is there a simple method of exporting all the symbols in an entire
> file? Simply put, I have a file with quite a few constants defined,
> and I'd rather not have a giant (export '(...)) list of symbols. I'd
> be just as happy with a method of exporting all symbols in a package,
> even.

shadow and redefine DEFCONSTANT:

(shadow 'defconstant)
(defmacro defconstant (symbol &body body)
  `(progn (export ',symbol) (cl:defconstant ,symbol ,@body)))

[untested]

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
A computer scientist is someone who fixes things that aren't broken.
From: John Thingstad
Subject: Re: Simple export?
Date: 
Message-ID: <opsh79idfgpqzri1@mjolner.upc.no>
On 27 Nov 2004 22:52:29 -0800, Jeff M. <·······@gmail.com> wrote:

> Is there a simple method of exporting all the symbols in an entire
> file? Simply put, I have a file with quite a few constants defined, and
> I'd rather not have a giant (export '(...)) list of symbols. I'd be
> just as happy with a method of exporting all symbols in a package,
> even.
>
> Thanks for any advice.
>
> Jeff M.
>

I usually just use emacs macroes to generate the export list.
This is typically done in a minute ore two.

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/