From: V.Ch.
Subject: How can I use a library?
Date: 
Message-ID: <d83dk7$87u$1@gavrilo.mtu.ru>
It must be a trivial question, but I still don't quite undestand how do 
you Lispers actually use libraries.
For instance, I want to use cl-ppcre (http://weitz.de/cl-ppcre/). I 
managed to install it using ASDF system. However, (require 'cl-ppcre) 
doesn't work - at least it doesn't work without specifying the path to 
the library. What's more, I don't understand whether I should use 
(require...) or (load...).
Apparently, there should be some portable way to specify the location 
(some equivalent of INCLUDE and LIB environmant variables).

Another question, do I understand correctly the there's no binary 
compatibility between libraries compiled with different Lisp compilers?

From: GP lisper
Subject: Re: How can I use a library?
Date: 
Message-ID: <1118126705.e348fd87dc8cd33ecc1c68c8e4025266@teranews>
On Tue, 07 Jun 2005 10:08:37 +0400, <····@not.real> wrote:
>
> For instance, I want to use cl-ppcre (http://weitz.de/cl-ppcre/). I 
> managed to install it using ASDF system. However, (require 'cl-ppcre) 
> doesn't work - at least it doesn't work without specifying the path to 

You need the paths setup in ASDF:*central-registry*

"require" probably only works out of the box on some lisps.  You fail
to mention which one you are using.

> the library. What's more, I don't understand whether I should use 
> (require...) or (load...).

You could (load blah) all the files usually picked up with (require :x).

> Apparently, there should be some portable way to specify the location 
> (some equivalent of INCLUDE and LIB environmant variables).

Why must it be portable?

A lisp core (or image) file is a "world", it already has the "INCLUDE"
and "LIB" pieces built in.

> Another question, do I understand correctly the there's no binary 
> compatibility between libraries compiled with different Lisp compilers?

Your point??  Are you seriously going to claim that Java can run
everywhere?

-- 
With sufficient thrust, pigs fly fine.
From: Ulrich Hobelmann
Subject: Re: How can I use a library?
Date: 
Message-ID: <3gl0sfFcsl0vU1@individual.net>
GP lisper wrote:
> On Tue, 07 Jun 2005 10:08:37 +0400, <····@not.real> wrote:
> 
>>For instance, I want to use cl-ppcre (http://weitz.de/cl-ppcre/). I 
>>managed to install it using ASDF system. However, (require 'cl-ppcre) 
>>doesn't work - at least it doesn't work without specifying the path to 
> 
> 
> You need the paths setup in ASDF:*central-registry*

Which works how?  Yesterday I tried PUSHing a directory with some 
.asd symlinks to *central-registry* (I use-package asdf), both as 
a string, and another time as #p"...", but asdf never found 
araneida and some other programs.  Only LOADing the .asd by hand 
worked.

-- 
Don't let school interfere with your education. -- Mark Twain
From: Edi Weitz
Subject: Re: How can I use a library?
Date: 
Message-ID: <u8y1m39ge.fsf@agharta.de>
On Tue, 07 Jun 2005 09:32:35 +0200, Ulrich Hobelmann <···········@web.de> wrote:

> GP lisper wrote:
>
>> You need the paths setup in ASDF:*central-registry*
>
> Which works how?

  <http://weitz.de/asdf-install/>

> Yesterday I tried PUSHing a directory with some .asd symlinks to
> *central-registry* (I use-package asdf), both as a string, and
> another time as #p"...", but asdf never found araneida and some
> other programs.  Only LOADing the .asd by hand worked.

You probably forgot the trailing slash.  Otherwise you should send a
bug report to the ASDF maintainers.

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: V.Ch.
Subject: Re: How can I use a library?
Date: 
Message-ID: <d83gik$93r$1@gavrilo.mtu.ru>
GP lisper wrote:
> 
> You need the paths setup in ASDF:*central-registry*

Set it up already, and can load cl-ppcre with ASDF. I just didn't 
realise I need to use ASDF all the time, even after the installation.

> "require" probably only works out of the box on some lisps.  You fail
> to mention which one you are using.

SBCL

> 
>>the library. What's more, I don't understand whether I should use 
>>(require...) or (load...).
> 
> 
> You could (load blah) all the files usually picked up with (require :x).

Don't quite understand you, will read it once again when not in a hurry.

> 
>>Apparently, there should be some portable way to specify the location 
>>(some equivalent of INCLUDE and LIB environmant variables).
> 
> 
> Why must it be portable?

It would have been nice ;)


> A lisp core (or image) file is a "world", it already has the "INCLUDE"
> and "LIB" pieces built in.

Again, failed to understand it right now.


>>Another question, do I understand correctly the there's no binary 
>>compatibility between libraries compiled with different Lisp compilers?
> 
> 
> Your point??  Are you seriously going to claim that Java can run
> everywhere?

Java?! What about Java?

However, C & C++ most certainly can run everywhere!
And here it's started again... ;)
From: ········@gmail.com
Subject: Re: How can I use a library?
Date: 
Message-ID: <1118127533.011790.270640@g43g2000cwa.googlegroups.com>
This is actually (and unfortunately) not a trivial question, and it
took me a while to understand as well...here's my newbie understanding
of it (anyone, please correct me if necessary):

In LISP terms, a 'system' is pretty much a buncha .lisp files that have
a lotta intra-dependency.  So they need to be loaded in a very specific
order.  Like, say you had utils.lisp, with lots of general use
functions.  It must be loaded first, because other files, say foo.lisp,
use functions defined in utils.lisp.

So you could write a script to load all the files in order...like:

(load "utils.lisp")
(load "foo.lisp")

Then in the REPL you just do (load "load.lisp") and the system is
loaded.  However, this can be cumbersome if you got tons of files and
complicated dependencies.  That's where ASDF comes in..
You tell it which files you want to load and which other files each
depend on, and it'll figure out the order in which to load them all (I
imagine it uses some topological sort algo).  It also does some other
nice things, like, not re-load systems that are already loaded.

So how do you use it?  First, load ASDF itself the old way:
(load "asdf/asdf.lisp") ;; or wherever you put it

Then load the ASD files for the packages.  The simplest way is to make
a unix-symbolic link in the current working dir to cl-ppcre.asd.  Then
just do:
(asdf:oos 'asdf:load-op :cl-ppcre)

Then you should be ready to go and do things like..
(cl-ppcre:do-matches ...) and stuff.

Notice I didn't use 'require' anywhere here.  I'm not sure how useful
require is, but I haven't had to use it.  And I've heard it's somewhat
incomplete in ANSI CL.

Hope that helped - good luck!

-Steve
From: ··········@gmail.com
Subject: Re: How can I use a library?
Date: 
Message-ID: <1118129147.088747.9150@g14g2000cwa.googlegroups.com>
In some lisp implementation (CMUCL and SBCL)
you can set up a hook that when you do a require, it is delegated to
asdf.

so in those system you can use require just like you would use
asdf:operate.

you also use asdf to use the library, not just install it.
It takes care of loading depended library in the correct order.

When you write your own system, you will find it very convenient to
create your system's asd file for loading the system.
From: Christopher C. Stacy
Subject: Re: How can I use a library?
Date: 
Message-ID: <u3brubomt.fsf@news.dtpq.com>
"V.Ch." <····@not.real> writes:
> Another question, do I understand correctly the there's no binary
> compatibility between libraries compiled with different Lisp compilers?

There is no standard format for the various kinds of binary
files that a Lisp compiler might product.  Some of them
output object (".o") files that can be linked with GCC.
Some of them do not compile to native code, and output
their own byte-code format.  Most of them output an
object format called a "FASL", which is different for
each compiler.  In many Lisp systems, applications may
delivered by creating a restartable dump file of the 
running Lisp image, which is called a "world load".
The commercial Lisp compilers, at least, are capable of 
creating standard executable formats (eg. ".EXE" on Windows)
and dynamic library (eg. ".DLL").

The ANSI standard for Lisp does not mandate anything in this area.  
I think it says there is to be some sort of FASL file, but it
doesn't say anything about what the format is.
From: Edi Weitz
Subject: Re: How can I use a library?
Date: 
Message-ID: <uacm2lm0o.fsf@agharta.de>
On Tue, 07 Jun 2005 10:08:37 +0400, "V.Ch." <····@not.real> wrote:

> It must be a trivial question, but I still don't quite undestand how
> do you Lispers actually use libraries.  For instance, I want to use
> cl-ppcre (http://weitz.de/cl-ppcre/). I managed to install it using
> ASDF system. However, (require 'cl-ppcre) doesn't work - at least it
> doesn't work without specifying the path to the library. What's
> more, I don't understand whether I should use (require...) or
> (load...).

Does this one help?

  <http://weitz.de/asdf-install/>

It's a tutorial for ASDF-INSTALL but it should also explain ASDF a
bit.

> Apparently, there should be some portable way to specify the
> location (some equivalent of INCLUDE and LIB environmant variables).

There isn't.  Note that INCLUDE and LIB aren't portable on Perl either
unless you use a Unix-like file structure on Windows.

> Another question, do I understand correctly the there's no binary
> compatibility between libraries compiled with different Lisp
> compilers?

That's right.  It's similar to using different C++ compilers.

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: V.Ch.
Subject: Re: How can I use a library?
Date: 
Message-ID: <d83fvo$8t7$1@gavrilo.mtu.ru>
Wow, thanks for such a quick response!

Edi Weitz wrote:
> Does this one help?
> 
>   <http://weitz.de/asdf-install/>
> 
> It's a tutorial for ASDF-INSTALL but it should also explain ASDF a
> bit.

Thanks!
I'll certainly read it.
I've skimmed through it already, and realised there's a mess with my 
understanding of what ASDF does. I thought one uses ASDF to install a 
library, not to use it. I can execute (asdf:operate 'asdf:load-op 
'cl-ppcre), however, I thought I am supposed to run it only once, 
because it takes some time even when cl-ppcre is compiled.

Btw, (asdf:operate 'asdf:load-op ...) looks a bit repulsive ;)

> There isn't.  Note that INCLUDE and LIB aren't portable on Perl either
> unless you use a Unix-like file structure on Windows.

Don't know anything about Perl, althout thinking right now about 
learning it (may be instead of Lisp, alas).


>>Another question, do I understand correctly the there's no binary
>>compatibility between libraries compiled with different Lisp
>>compilers?
> 
> That's right.  It's similar to using different C++ compilers.

Well, that's not quite true. As long as you stick to exporting plain C 
functions, you should be fine. In some cases you'll probably get away 
with exporting classes, and I think that in the end they will define an 
ABI for C++ that all compilers will adhere to.
From: ········@gmail.com
Subject: Re: How can I use a library?
Date: 
Message-ID: <1118127757.144340.4510@g49g2000cwa.googlegroups.com>
> Btw, (asdf:operate 'asdf:load-op ...) looks a bit repulsive ;)

The great thing about lisp is that if it looks repulsive, you can make
it pretty:

(defun asdf-load (&rest system-names)
  (dolist (system-name system-names)
	(asdf:oos 'asdf:load-op system-name)))

So now you can do:

(asdf-load :cl-ppcre :cl-foo :cl-mysystem :cl-ad-infinitum)

OK, not the most amazing example of LISP's power..see Practical Common
Lisp for those :P
From: Thomas F. Burdick
Subject: Re: How can I use a library?
Date: 
Message-ID: <xcvu0ka4mr9.fsf@conquest.OCF.Berkeley.EDU>
"V.Ch." <····@not.real> writes:

> Btw, (asdf:operate 'asdf:load-op ...) looks a bit repulsive ;)

ASDF is a fairly low-level library for defining and operating on
systems.  If you use SLIME, you can use the ", load-system" command at
the REPL, which is much nicer.

> >>Another question, do I understand correctly the there's no binary
> >>compatibility between libraries compiled with different Lisp
> >>compilers?
> > 
> > That's right.  It's similar to using different C++ compilers.
> 
> Well, that's not quite true. As long as you stick to exporting plain C 
> functions, you should be fine. In some cases you'll probably get away 
> with exporting classes, and I think that in the end they will define an 
> ABI for C++ that all compilers will adhere to.

AFAIK, except on Solaris, you can't expect to reliably link C++
against C++ unless both parts were compiled with the same compiler.
The compilers usually go out of their way to prevent it from even
working a little, because otherwise users would complain if they broke
that minimal compatability.  Yes, you can call through a C interface,
but you lose all of the gains of C++ over C, at least in the
interface.  You can do the same with Lisp, too, but the lossage in
moving from Lisp to C is much greater.

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | Free Mumia Abu-Jamal! |
     ,--'    _,'   | Abolish the racist    |
    /       /      | death penalty!        |
   (   -.  |       `-----------------------'
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Edi Weitz
Subject: Re: How can I use a library?
Date: 
Message-ID: <u4qca3915.fsf@agharta.de>
On Tue, 07 Jun 2005 10:48:54 +0400, "V.Ch." <····@not.real> wrote:

> Wow, thanks for such a quick response!

Glad to be at your service... :)

> I've skimmed through it already, and realised there's a mess with my
> understanding of what ASDF does. I thought one uses ASDF to install
> a library, not to use it.

In order to /use/ it you have to /load/ it.  ASDF can be used to
/compile/ libs as well as /load/ them.

> I can execute (asdf:operate 'asdf:load-op cl-ppcre), however, I
> thought I am supposed to run it only once, because it takes some
> time even when cl-ppcre is compiled.

CL-PPCRE might not be the best example because it does some
computations at load time.  Smaller and simpler libraries should load
very quickly once they're compiled.

> Btw, (asdf:operate 'asdf:load-op ...) looks a bit repulsive ;)

So, write a shortcut for it... :)

> Don't know anything about Perl, 

Sorry, I confused you with another newbie who posted here recently.

> althout thinking right now about learning it (may be instead of
> Lisp, alas).

I've done mostly Perl before I switched to CL and I can only advise
you not to do that.  But, hey, it's your life... :)

> Well, that's not quite true. As long as you stick to exporting plain
> C functions, you should be fine. In some cases you'll probably get
> away with exporting classes, and I think that in the end they will
> define an ABI for C++ that all compilers will adhere to.

Well, maybe in the end "they" (whoever that is) will define a common
FASL format all Lisp compilers will adhere to.  I wouldn't hold my
breath, though... :)

Seriously - it's a good thing that there's a choice between several
Lisp implementations based on the same ANSI standard.  However,
everyone who uses CL in earnest will sooner or later decide to use
/one/ implementation and then questions like these become moot.

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Peter Scott
Subject: Re: How can I use a library?
Date: 
Message-ID: <1118160809.221923.207090@f14g2000cwb.googlegroups.com>
If you're using SBCL, here's a quick walkthrough installing cl-ppcre
(or any other asdf-installable library):

;; Load some libraries which should come with SBCL
(require :asdf)
(require :asdf-install)
;; Fetch the thing from the internet and compile it
(asdf-install:install :cl-ppcre)
;; You will be asked some questions. Just fumble through.

When you want to use cl-ppcre after this, just load it with
(require :cl-ppcre)
and you're set. After a while this sort of thing gets easy.

-Peter