[Openmcl-devel] Clozure/Lisp newbie question

Gerry Weaver gerryw at compvia.com
Thu Apr 12 16:46:53 PDT 2012


Hi Pascal,

Wow!! I really appreciate your help!! This took you some time to type up. Thanks for such a great description of the options available. I am reading up on adsf and quicklisp.

Thanks Again,
-G


________________________________________
From: openmcl-devel-bounces at clozure.com [openmcl-devel-bounces at clozure.com] on behalf of Pascal J. Bourguignon [pjb at informatimago.com]
Sent: Thursday, April 12, 2012 5:06 PM
To: openmcl-devel at clozure.com
Subject: Re: [Openmcl-devel] Clozure/Lisp newbie question

Gerry Weaver <gerryw at compvia.com> writes:

> What is the best way to move code between platforms or
> implementations? Do you just move the source files and load them into
> the target image? I'm still trying to get my brain wrapped around the
> image thing.
>
> Thanks for your responses. They are very helpful to a newbie trying to get started.

Depends.

You may indeed use a simple approach, using raw tools.

So let's say you have three files:

    packages.lisp      -- contains defpackage forms.
    macros.lisp        -- contains defmacro forms
    functions.lisp     -- contains defun forms.

you can write a simple loader.lisp file:

    loader.lisp        -- contains instruction to build the program.

---loader.lisp-----------------------------------------

(dolist (file '("package" "macros" "functions"))
   (load (compile-file file)))

-------------------------------------------------------

This ensures the simple dependency graph:

    packages <-- macros <-- functions

meanings that to compile macros.lisp, you must have compiled and loaded
packages.lisp, since macros.lisp contains a (in-package :you-package)
form, and to compile functions.lisp, you must have compiled and loaded
macros.lisp, since functions.lisp contains calls to macros defined in
macros.lisp.

So you have those four files in a directory named project, and indeed,
you may simply do:

    scp -r project/ user at remote:~/project
    ssh user at remote
    cd ~/project
    ccl
    (load "loader.lisp")
    (your-package:run)

But if you have more files, it will soon become boring recompiling
everything everytime. You want something like make(1), which  compiles
only the files it needs depending on the changes you make. So if you
change macros.lisp,  you need to recompile it and functions.lisp, but
not packages.lisp.

For this you'd use asdf.

Then since you're working on different computers, it will become
difficult to track what you've changed on one computer or on another, so
you will wnat to use a SCM.  A lot of people use git nowadays. For some
uses, I also like fossil http://fossil-scm.org/ (it can import and
export from git repositories).  You will need to setup a server to store
a common repository (either a http or git server), or you may use a
public git server. I use gitorious or my own servers but a lot of people
use github.

Furthermore, your programs may need to use libraries, and an easy way to
install a lisp library, with all its dependencies, is to use quicklisp.

http://git-scm.com/
http://fossil-scm.org/

http://github.com/
http://gitorious.org/                  -- notice a pattern?

http://common-lisp.net/project/asdf/asdf/
http://www.quicklisp.org/

https://github.com/xach/quickproject

http://www.cliki.net/Getting%20Started

So finally your workflow would be:


cd ~/project RET
emacs RET
M-x slime RET
(ql:quickload :your-program)
(your-program:main)
;; (loop while bugs do enter slime debugger, debug, correct sources)
,restart -- to restart with a fresh image.
(ql:quickload :your-program)
(your-program:main)
;; check that everything's ok.
M-x shell RET
git add ${new_files_you_ve_added}
git commit -a -m ${commit_message}
git push
xterm -e ssh -X -Y user at remote RET
emacs RET
M-x shell RET
cd ~/project RET
git pull
M-x slime RET
(ql:quickload :your-program)
(your-program:main)

etc.



--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.

_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list