Subject: Re: Common Lisp from a Unix perspective - barriers to using CL
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 13 Dec 2006 06:08:07 -0600
Newsgroups: comp.lang.lisp
Message-ID: <m7GdnZ6gkpa6cOLYnZ2dnUVZ_sKunZ2d@speakeasy.net>
Don Geddis  <don@geddis.org> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) wrote:
| > [The "-script" switch for CMUCL is a local hack to "site-init.lisp"
| > that I've been intending to publish for several years. My bad.
| > Soon, soon...]
| 
| Now that looks awesome, and quite useful.
+---------------

Thanks. It also works if you just slap the "#!" line in front of a
FASL files. Oh... Did you know you can make a legal CMUCL FASL file
by simply concatenating several FASL files together? Yup. The CMUCL
FASL reader supports that. And so it works with the script hack, too:

    $ head script_header.cmu foo[123].lisp
    ==> script_header.cmu <==
    #!/usr/local/bin/cmucl -script

    ==> foo1.lisp <==
    (defun foo1 () (format t "This is foo1.~%"))

    ==> foo2.lisp <==
    (defun foo2 () (format t "This is foo2.~%"))

    ==> foo3.lisp <==
    (declaim (ftype function foo1 foo2))  ; muffle warnings
    (foo1)
    (foo2)
    $ cmu-compile foo[123].lisp     # "cmu-compile" is itself a small script
    ...[chatter]...
    ; foo1.x86f written.
    ...
    ; foo1.x86f written.
    ...
    ; foo3.x86f written.
    ; Compilation finished in 0:00:00.
    $ cat script_header.cmu foo[123].x86f > foo
    $ chmod a+x foo
    $ ./foo
    This is foo1.
    This is foo2.
    $ 

What you can't do is mix source code and FASLs in the same "script".  ;-}

+---------------
| Besides just publishing it, could it be added to the main branch
| of the CMUCL code?
+---------------

I've been talking recently to one of the maintainers about that
very thing. But it's a really ugly hack [though short, only ~30
lines for the most interesting bits] since it completely usurps
the normal command-line option processing. It would be good if
a cleaner approach could be taken for the standard distribution.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607