From: dstein64
Subject: Packages and ASDF
Date: 
Message-ID: <f7d20324-656c-40de-b6a7-f09b79b6a774@t54g2000hsg.googlegroups.com>
I am still new to lisp and I am having a hard time figuring out how
the ASDF and package system works. For example, how come clc is not
listed in *modules* but I am able to access its symbols nonetheless
(Like clc:list-symbols)? How does my lisp implementation (SBCL) know
where to look? And then how come for other packages (or systems, I am
still unsure of the difference), I must first type (require :package-
name), before I can access its symbols? I have a few more similar
questions, but an answer to this will probably allow me to draw
further conclusions. Also, if you know of any sites that might explain
the difference between packages and systems and how everything works
(like which variables store the directories that are searched, or
which variables list all the packages that can be accessed), that
would be great. Thanks.

From: Victor Kryukov
Subject: Re: Packages and ASDF
Date: 
Message-ID: <m2fxuggcwk.fsf@gmail.com>
dstein64 <········@gmail.com> writes:

> I am still new to lisp and I am having a hard time figuring out how
> the ASDF and package system works. For example, how come clc is not
> listed in *modules* but I am able to access its symbols nonetheless
> (Like clc:list-symbols)? How does my lisp implementation (SBCL) know
> where to look? And then how come for other packages (or systems, I am
> still unsure of the difference), I must first type (require :package-
> name), before I can access its symbols? I have a few more similar
> questions, but an answer to this will probably allow me to draw
> further conclusions. Also, if you know of any sites that might explain
> the difference between packages and systems and how everything works
> (like which variables store the directories that are searched, or
> which variables list all the packages that can be accessed), that
> would be great. Thanks.

This is a good introduction: www.flownet.com/ron/packages.pdf. This is
another one: http://weitz.de/packages.html

To quote Edi Weitz,

   At least once per week (my personal estimate) some "newbie" on
   c.l.l or a Lisp-related mailing list seems to be confused about
   packages one way or the other. They talk about "loading" packages,
   "requiring" packages, they wonder why, after loading a system, they
   still have to use package markers, and so on.

Enjoy :).

Regards,
Victor

-- 
http://macrodefinition.blogspot.com
From: Ron Garret
Subject: Re: Packages and ASDF
Date: 
Message-ID: <rNOSPAMon-546273.22022524032008@news.gha.chartermi.net>
In article <··············@gmail.com>,
 Victor Kryukov <··············@gmail.com> wrote:

> dstein64 <········@gmail.com> writes:
> 
> > I am still new to lisp and I am having a hard time figuring out how
> > the ASDF and package system works. For example, how come clc is not
> > listed in *modules* but I am able to access its symbols nonetheless
> > (Like clc:list-symbols)? How does my lisp implementation (SBCL) know
> > where to look? And then how come for other packages (or systems, I am
> > still unsure of the difference), I must first type (require :package-
> > name), before I can access its symbols? I have a few more similar
> > questions, but an answer to this will probably allow me to draw
> > further conclusions. Also, if you know of any sites that might explain
> > the difference between packages and systems and how everything works
> > (like which variables store the directories that are searched, or
> > which variables list all the packages that can be accessed), that
> > would be great. Thanks.
> 
> This is a good introduction: www.flownet.com/ron/packages.pdf. This is
> another one: http://weitz.de/packages.html
> 
> To quote Edi Weitz,
> 
>    At least once per week (my personal estimate) some "newbie" on
>    c.l.l or a Lisp-related mailing list seems to be confused about
>    packages one way or the other. They talk about "loading" packages,
>    "requiring" packages, they wonder why, after loading a system, they
>    still have to use package markers, and so on.

And if you get tired of futzing with all that, try lexicons.

http://www.flownet.com/ron/lisp/Lexicons.pdf

(Note that this document is now slightly out of date.  If you want to 
actually use the lexicon code let me know and I'll update it.)

rg
From: dstein64
Subject: Re: Packages and ASDF
Date: 
Message-ID: <74683c12-33ec-41c8-a7e8-3aca12da3e54@n58g2000hsf.googlegroups.com>
Thanks for all the replies. The links have been very helpful and
Neil's explanations answered a lot of questions. So I now have a
clearer understanding of the package/system distinction, but I am
still unsure how I should work with these files. If 'require' is
deprecated, what is the recommended way of working with a system. For
example, I use acl-compat, and I have been typing (require :acl-
compat) and then (in-package :acl-socket), which seems to work fine.
Is there a method that is suggested? Also, there were numerous
mentions of a Lisp Image. Where should I read more about that? Thanks.
From: dstein64
Subject: Re: Packages and ASDF
Date: 
Message-ID: <ff943bfc-e3b8-4dbb-85a4-8c558b392ebe@e39g2000hsf.googlegroups.com>
And lastly, in addition to my last question: Is there any way, from
the REPL, to get a list of all available packages in the current
session? Thanks again.
From: John Thingstad
Subject: Re: Packages and ASDF
Date: 
Message-ID: <op.t8ktwpxkut4oq5@pandora.alfanett.no>
P� Tue, 25 Mar 2008 15:17:13 +0100, skrev dstein64 <········@gmail.com>:

> And lastly, in addition to my last question: Is there any way, from
> the REPL, to get a list of all available packages in the current
> session? Thanks again.


(list-all-packages)

--------------
John Thingstad
From: Edi Weitz
Subject: Re: Packages and ASDF
Date: 
Message-ID: <utziuakbk.fsf@agharta.de>
On Tue, 25 Mar 2008 07:17:13 -0700 (PDT), dstein64 <········@gmail.com> wrote:

> Is there any way, from the REPL, to get a list of all available
> packages in the current session?

What excatly do you mean when you say "available"?  You can get a list
of all /existing/ packages (see other answers), but if you're asking
about all "available" packages, I sense some confusion.

Edi.

-- 

European Common Lisp Meeting, Amsterdam, April 19/20, 2008

  http://weitz.de/eclm2008/

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: dstein64
Subject: Re: Packages and ASDF
Date: 
Message-ID: <bd725789-1de6-4a33-acb0-f9a2c2e9a5c0@s50g2000hsb.googlegroups.com>
>
> What excatly do you mean when you say "available"?  You can get a list
> of all /existing/ packages (see other answers), but if you're asking
> about all "available" packages, I sense some confusion.
>

I almost reposted immediately after writing 'available', as I was
unsure if I worded my thoughts properly. What I meant to say is, how
can I check what packages have been defined in the current image.

Thanks again for the replies. It seems like everything just clicked
after reading enough responses.
From: John Thingstad
Subject: Re: Packages and ASDF
Date: 
Message-ID: <op.t8kt7aoput4oq5@pandora.alfanett.no>
P� Tue, 25 Mar 2008 14:23:15 +0100, skrev dstein64 <········@gmail.com>:

> Thanks for all the replies. The links have been very helpful and
> Neil's explanations answered a lot of questions. So I now have a
> clearer understanding of the package/system distinction, but I am
> still unsure how I should work with these files. If 'require' is
> deprecated, what is the recommended way of working with a system. For
> example, I use acl-compat, and I have been typing (require :acl-
> compat) and then (in-package :acl-socket), which seems to work fine.
> Is there a method that is suggested? Also, there were numerous
> mentions of a Lisp Image. Where should I read more about that? Thanks.

 From the SBCL documentation check out save-lisp-and-die.

--------------
John Thingstad
From: Edi Weitz
Subject: Re: Packages and ASDF
Date: 
Message-ID: <uy786akfq.fsf@agharta.de>
On Tue, 25 Mar 2008 06:23:15 -0700 (PDT), dstein64 <········@gmail.com> wrote:

> If 'require' is deprecated, what is the recommended way of working
> with a system.

The answer depends on the system definition facility you are using.
If it is ASDF, then (asdf:oos 'asdf:load-op :system-name) is the way
to go (SLIME and other IDEs have shortcuts for this), but if it is,
say, MK:DEFSYSTEM or Common Defsystem, then the answer is different.

> For example, I use acl-compat, and I have been typing (require :acl-
> compat) and then (in-package :acl-socket), which seems to work fine.

Then why don't you continue doing so?

But note that you are only talking about interactive usage here.
Assuming that you'll eventually spend most of your time writing code
and not only trying things out in the REPL, you should have a
different workflow.

  http://weitz.de/packages.html#code

> Also, there were numerous mentions of a Lisp Image.

Most Lisps have a way of saving their current state to disk so that
you can continue at this point at some later time.  These states or
files are usually called "images" or sometimes "worlds" and what
you're working in is also some image that was at one time saved.  The
commands to save images are implementation-dependent.

Edi.

-- 

European Common Lisp Meeting, Amsterdam, April 19/20, 2008

  http://weitz.de/eclm2008/

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Pascal J. Bourguignon
Subject: Re: Packages and ASDF
Date: 
Message-ID: <7ck5jqu801.fsf@pbourguignon.anevia.com>
dstein64 <········@gmail.com> writes:

> Thanks for all the replies. The links have been very helpful and
> Neil's explanations answered a lot of questions. So I now have a
> clearer understanding of the package/system distinction, but I am
> still unsure how I should work with these files. If 'require' is
> deprecated, what is the recommended way of working with a system. 

ASDF.

> For
> example, I use acl-compat, and I have been typing (require :acl-
> compat) and then (in-package :acl-socket), which seems to work fine.

I'd do:

(asdf-load :acl-compat)
(in-package :acl-socket)

But:

1- There must be a way to locate and load ASDF.  Since I define
   logical pathnames, I can load my ASDF the same on all the
   implementations I use, well, almost, for allegro you have to
   downcase yourself the logical path:

       (LOAD (#+allegro lp
              #-allegro identity
                   "PACKAGES:NET;SOURCEFORGE;CCLAN;ASDF;ASDF.LISP"))

   Sbcl users can just do (require :asdf).

2- Since the syntax of asdf is not nice to type interactively, I
   defined my own asdf-load functions:

(defun asdf-load        (system) (asdf:operate 'asdf:load-op        system))
(defun asdf-load-source (system) (asdf:operate 'asdf:load-source-op system))



> Is there a method that is suggested? 

Note that CL:REQUIRE is perfectly 'safe' (ie. portable) when you give
it two arguments.

(require 'my-module #P"MODULES:MINE;MY-MODULE.LISP")

Or, if you're on a POSIX system, 
(require 'my-module #P"/usr/share/lisp/modules/mine/my-module.lisp")
may work.


So if you used:

(require :asdf 
    (#+allegro lp
     #-allegro identity
         "PACKAGES:NET;SOURCEFORGE;CCLAN;ASDF;ASDF.LISP"))

it could work on all the systems.


> Also, there were numerous
> mentions of a Lisp Image. Where should I read more about that? Thanks.

http://clisp.cons.org/impnotes/image.html

-- 
__Pascal Bourguignon__
From: Neil Baylis
Subject: Re: Packages and ASDF
Date: 
Message-ID: <74847e24-e920-4210-b139-2547ee1ad302@n77g2000hse.googlegroups.com>
On Mar 24, 11:50 am, dstein64 <········@gmail.com> wrote:
> I am still new to lisp and I am having a hard time figuring out how
> the ASDF and package system works. For example, how come clc is not
> listed in *modules* but I am able to access its symbols nonetheless
> (Like clc:list-symbols)? How does my lisp implementation (SBCL) know
> where to look? And then how come for other packages (or systems, I am
> still unsure of the difference), I must first type (require :package-
> name), before I can access its symbols? I have a few more similar
> questions, but an answer to this will probably allow me to draw
> further conclusions. Also, if you know of any sites that might explain
> the difference between packages and systems and how everything works
> (like which variables store the directories that are searched, or
> which variables list all the packages that can be accessed), that
> would be great. Thanks.

I feel your pain.

As far as I can tell, a module is a file. More specifcally, perhaps it
would be correct to say that a module is whatever is loaded by
(require...) or provided by (provide...), which is usually a file,
either .lisp source or .fasl compiled code.

If you (provide...) something, then it will be added to the list
*modules*. If you (require...) something, and it's not already in the
list *modules*, then Cl will look in a list named *module-provider-
functions* for a function that knows how to provide the thing you are
trying to require. You can add your own functions to this list to make
it search wherever you want. Supposedly, provide & require are
deprecated, but apparently some folks still use them anyway.

SBCL adds a function to *module-provider-functions* that will find
anything that has been installed via asdf-install. That's why you can
do (require :foo) in SBCL, and it will find foo if it it was installed
by asdf-install. This is very handy, but it confused me at first.

A package is a namespace. It gives you a way to qualify names so you
can avoid naming conflicts. I found Peter Seibel's book better at
explaining packages then Ron Garret's paper. Also watch Marco
Baringer's video for hints about setting up a simple package. As a
beginner, you can't watch that video too many times. You might think
of a package as a collection (or container) of functions and symbols,
although it's actually a bit more complicated than that.

A "system" is whatever is handled by asdf. Think of asdf as equivalent
to make, and a xxx.asd file as equivalent to a makefile. (There are
alternatives to asdf as well, but I don't know anything about them). A
system will comprise one or more lisp files with dependencies among
them. You might think of a system as a collection of packages,
probably with dependencies among them.

asdf-install is a tool that downloads systems and installs them so
that asdf can load them. In the case of SBCL, it also means that
(require...) can load them. It's roughly analogous to apt-get, but
used for lisp systems.

To summarize:

asdf-install installs systems into the right place on your computer.
i.e., asdf-central-registry
asdf loads systems from asdf-central-registry into your lisp.
(require...) loads modules by calling functions from *module-provider-
functions*
(provide...) causes module names to be added to *modules*
(load...) loads lisp code (e.g. .lisp or .fasl files) into your lisp.
From: Thomas A. Russ
Subject: Re: Packages and ASDF
Date: 
Message-ID: <ymi7ifqpy55.fsf@blackcat.isi.edu>
Neil Baylis <···········@gmail.com> writes:
> You might think
> of a package as a collection (or container) of functions and symbols,
> although it's actually a bit more complicated than that.

While there are more complicated aspects to package management,
especially through import, export and shadowing, it is important to
understand that a package deals ONLY with symbols.  Function definitions
and global (special) values are properties of symbols, but they do not
depend on the package of the symbol.

Functions and values can be assigned to any symbol, regardless of where
that symbol comes from.  This sometimes leads to confusion for new Lisp
users since you can't, for example, just export the class P:FOO and not
export the function P:FOO as well.  Symbols are just symbols, and what
they name is orthogonal to the package issue -- which is just concerned
with the mapping of print names to symbol objects.

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Drew Crampsie
Subject: Re: Packages and ASDF
Date: 
Message-ID: <47e7fb84$0$26078$88260bb3@free.teranews.com>
On Mon, 24 Mar 2008 11:50:40 -0700, dstein64 wrote:

> I am still new to lisp and I am having a hard time figuring out how the
> ASDF and package system works. 

http://www.fuckinggoogleit.com/?q=asdf+manual
http://www.fuckinggoogleit.com/?q=idiots+guide+to+packages

Packages and systems are orthogonal to each other. 


For example, how come clc is not listed
> in *modules* but I am able to access its symbols nonetheless (Like
> clc:list-symbols)?

The ansi common lisp 'module system' is orthogonal to the package system 
as well. It is also underspecified, unused, depreciated, and safe to 
ignore it for now. 

CLC is another things altogether. The best advice i can give is to not 
use CLC, install your SBCL from tarball or source. CLC solves certain 
problems, but those problems are those of software disrtibutors, not 
developers.  

> How does my lisp implementation (SBCL) know where to
> look? 

It doesn't... asdf does via it's exported interface. RTFM will help you 
here.

> And then how come for other packages (or systems, I am still
> unsure of the difference), I must first type (require :package- name),
> before I can access its symbols? 

Because packages, systems and modules are all different things that 
you've gotten all confused :). http://www.gigamonkeys.com/book/
programming-in-the-large-packages-and-symbols.html might help some more.

>I have a few more similar questions,
> but an answer to this will probably allow me to draw further
> conclusions. Also, if you know of any sites that might explain the
> difference between packages and systems and how everything works (like
> which variables store the directories that are searched, or which
> variables list all the packages that can be accessed), that would be
> great. Thanks.

Check out those links i gave you, and google the rest.

Cheers, 

drewc

-- 
Posted via a free Usenet account from http://www.teranews.com
From: John Thingstad
Subject: Re: Packages and ASDF
Date: 
Message-ID: <op.t8jbuakiut4oq5@pandora.alfanett.no>
P� Mon, 24 Mar 2008 19:50:40 +0100, skrev dstein64 <········@gmail.com>:

> I am still new to lisp and I am having a hard time figuring out how
> the ASDF and package system works. For example, how come clc is not
> listed in *modules* but I am able to access its symbols nonetheless
> (Like clc:list-symbols)? How does my lisp implementation (SBCL) know
> where to look? And then how come for other packages (or systems, I am
> still unsure of the difference), I must first type (require :package-
> name), before I can access its symbols? I have a few more similar
> questions, but an answer to this will probably allow me to draw
> further conclusions. Also, if you know of any sites that might explain
> the difference between packages and systems and how everything works
> (like which variables store the directories that are searched, or
> which variables list all the packages that can be accessed), that
> would be great. Thanks.

Well for packages Ron Garreth's guide is pretty good.
www.flownet.com/ron/packages.pdf

Some of SBCL's packages are already in the lisp image thus you don't need  
to load them.
See the SBCL manual.

For ASDF the best guide is the ASDF manual I think.

--------------
John Thingstad
From: Thomas A. Russ
Subject: Re: Packages and ASDF
Date: 
Message-ID: <ymibq52pybz.fsf@blackcat.isi.edu>
dstein64 <········@gmail.com> writes:

> I am still new to lisp and I am having a hard time figuring out how
> the ASDF and package system works.

One important concept to master is that ASDF and packages are completely
different things.

A package is a namespace that is used to control the mapping from symbol
names (strings) to symbol objects.  That is all that it does.  Packages
interact with the reader to enable this mapping to occur and (for
interned symbols) to make sure that the same symbol object is found each
time the same name is read.  (Here "same name" refers to the same
package-qualified name).

ASDF is used to install software modules or systems.  REQUIRE/PROVIDE
also do something similar, and are part of the Common Lisp standard, but
the behavior is largely left up to the implementation.  In some cases,
like SBCL, the implementation uses ASDF behind the scenes to implement
require and provide.  Other system building and packaging tools are
various versions of DEFSYSTEM, most prominently MK-DEFSYSTEM.  IIRC ACL
ships with defsystem.

> For example, how come clc is not
> listed in *modules* but I am able to access its symbols nonetheless
> (Like clc:list-symbols)?

That is because packages and modules are completely different things.
Now there is perhaps some confusion because a module or system or
collection of code usually has one or more packages of its own.  That is
because it is good programming practice to have a separate package for
each separate system or library.  That way you can have multiple
libraries present at the same time without having to worry about name
collisions.  So modules often come with packages of their own, but the
important thing is that those are different concepts.  You can have one
without the other.

Typically a system will include a DEFPACKAGE form that defines the
package(s) used in that system.  Until such a system is loaded, the
system will not have any record of he existence of that package, because
it hasn't been created.  If code has been loaded, perhaps even without
using any of the system management tools, it could also define a
package, which would create symbols in that package.


-- 
Thomas A. Russ,  USC/Information Sciences Institute