Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

You know that something is off in the universe, when...

135 views
Skip to first unread message

Yves S. Garret

unread,
Sep 5, 2012, 2:42:18 PM9/5/12
to
[3]> (load (compile-life "hello-world.lisp"))

*** - EVAL: undefined function COMPILE-LIFE
...

:)

I need a vacation.

Yves S. Garret

unread,
Sep 5, 2012, 4:27:05 PM9/5/12
to
Someone responded to me in private and suggested I use this method:

(defun cl (f)
(load (compile-file f)))

How can I make this load automatically every time I start up lisp?

Kaz Kylheku

unread,
Sep 5, 2012, 6:30:48 PM9/5/12
to
On 2012-09-05, Yves S. Garret <yoursurr...@gmail.com> wrote:
> Someone responded to me in private and suggested I use this method:
>
> (defun cl (f)
> (load (compile-file f)))
>
> How can I make this load automatically every time I start up lisp?

But that happens, oh, once every power blackout? Who cares ... :)

But seriously: just look into the documentation for your Lisp.

Lisps that can be run from an operating system command line often have an
argument for specifying an expression to be evaluated.

In that case you can create some command alias to invoke that Lisp
and load a file at the same time.

Some may have an rc file. For instance CLISP looks for a .clisprc in your
home directory.

Pascal J. Bourguignon

unread,
Sep 5, 2012, 9:45:30 PM9/5/12
to
Each implementation of COMMON LISP use a different rc file:

.clinit.cl
.clisprc.lisp
.cmucl-init.lisp
.eclrc
.gclrc.lisp
.sbclrc
.abclrc
ccl-init.lisp
openmcl-init.lisp

My advice is to create a file ~/rc/common.lisp
and to put your definitions there:


----(~/rc/common.lisp)--------------------------------------------------
(in-package :cl-user)
(defun cl (f)
(load (compile-file f)))
------------------------------------------------------------------------



then to add to each of the implementation specific rc files:

(LET ((*LOAD-VERBOSE* NIL))
(LOAD (MERGE-PATHNAMES
#-abcl
(MAKE-PATHNAME :DIRECTORY '(:RELATIVE "RC") :NAME "COMMON" :TYPE "LISP"
:CASE :COMMON)
#+abcl
(MAKE-PATHNAME :DIRECTORY '(:RELATIVE "rc") :NAME "common" :TYPE "lisp"
:CASE :LOCAL)
(USER-HOMEDIR-PATHNAME)
NIL)))


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

Yves S. Garret

unread,
Sep 6, 2012, 10:07:56 AM9/6/12
to
Thanks everyone. I did some digging and experimentation for Common Lisp in Cygwin and .clisprc.lisp was the file I needed. I put in the following code in the file:

(defun cl(f)
(load (compile-file f)))

Now, when I load the file, I get this:
;; Loading file /home/foo/.clisprc.lisp
;; Loaded file /home/foo/.clisprc.lisp

And when I tried running (cl "hello-world.lisp"), it worked!

Zach Beane

unread,
Sep 6, 2012, 10:11:19 AM9/6/12
to
"Yves S. Garret" <yoursurr...@gmail.com> writes:

I like to name such functions with keywords, so I can type them without
a prefix regardless of the current REPL value of *package*. So the call
would look like this instead:

(:cl "hello-world.lisp")

Zach

Yves S. Garret

unread,
Sep 6, 2012, 10:27:01 AM9/6/12
to
Not a bad idea. I'll incorporate it.

Madhu

unread,
Sep 6, 2012, 11:30:57 AM9/6/12
to

* "Yves S. Garret" <8f591af0-10e5-471e...@googlegroups.com> :
Wrote on Thu, 6 Sep 2012 07:27:01 -0700 (PDT):

|> I like to name such functions with keywords, so I can type them without
|> a prefix regardless of the current REPL value of *package*.
|
| Not a bad idea. I'll incorporate it.

I think it is a terrible idea to define functions visible from the
KEYWORD package, which is a special package in many respects, but coming
from Zach, the advice is in line with developing the new breed of CL
consumers. --- Madhu

Zach Beane

unread,
Sep 6, 2012, 11:34:38 AM9/6/12
to
Madhu <eno...@meer.net> writes:

> * "Yves S. Garret" <8f591af0-10e5-471e...@googlegroups.com> :
> Wrote on Thu, 6 Sep 2012 07:27:01 -0700 (PDT):
>
> |> I like to name such functions with keywords, so I can type them without
> |> a prefix regardless of the current REPL value of *package*.
> |
> | Not a bad idea. I'll incorporate it.
>
> I think it is a terrible idea to define functions visible from the
> KEYWORD package,

What are some of the drawbacks of the practice?

Zach

Chris Riesbeck

unread,
Sep 6, 2012, 1:48:09 PM9/6/12
to
Collisions between libraries. Same reason you don't want to use keywords
on property lists.

http://www.lispworks.com/documentation/HyperSpec/Body/11_abcb.htm

I had in fact thought it was non-portable to DEFUN a keyword, but that
was from a line in CLtL:

> Such symbols must be easily accessible from any package, and name conflicts
> are not an issue because these symbols are used only as labels and never
> to carry package-specific values or properties.


http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node114.html


Zach Beane

unread,
Sep 6, 2012, 1:50:00 PM9/6/12
to
Chris Riesbeck <Chris.R...@gmail.com> writes:

> On 9/6/2012 10:34 AM, Zach Beane wrote:
>> Madhu <eno...@meer.net> writes:
>>
>>> * "Yves S. Garret" <8f591af0-10e5-471e...@googlegroups.com> :
>>> Wrote on Thu, 6 Sep 2012 07:27:01 -0700 (PDT):
>>>
>>> |> I like to name such functions with keywords, so I can type them without
>>> |> a prefix regardless of the current REPL value of *package*.
>>> |
>>> | Not a bad idea. I'll incorporate it.
>>>
>>> I think it is a terrible idea to define functions visible from the
>>> KEYWORD package,
>>
>> What are some of the drawbacks of the practice?
>
> Collisions between libraries. Same reason you don't want to use
> keywords on property lists.

Ah, but I would never put a function named by a keyword into a source
file; I define them exclusively in my Lisp initialization file and use
them exclusively in the REPL.

Zach

Yves S. Garret

unread,
Sep 6, 2012, 4:21:34 PM9/6/12
to
I figured that that was the reason why you included the colon before the "cl", to pick a standard that's so different, that it would not interfere with other macros, methods, etc.

Kaz Kylheku

unread,
Sep 6, 2012, 5:01:44 PM9/6/12
to
Keywords can have function bindings? Now that I think of it, why would that be forbidden,
given we have a Lisp-2. And actually the self-evaluating of keywords is understood as a kind
of binding.

But how about something else. The following works in CLISP:

[3]> (defun t () 42)
T
[4]> (t)
42

Now, that's some nasty Lisp p0rn.

Pascal J. Bourguignon

unread,
Sep 6, 2012, 6:57:07 PM9/6/12
to
Unfortunately, some (oldish) codes do name a few functions with keywords.


But otherwise, it's of the same level as defining short names or
nicknames to packages in libraries.

That is: don't do that in libraries,
but it's ok to do that in your rc files.

Pascal J. Bourguignon

unread,
Sep 6, 2012, 6:59:02 PM9/6/12
to
Kaz Kylheku <k...@kylheku.com> writes:

> Keywords can have function bindings? Now that I think of it, why would that be forbidden,
> given we have a Lisp-2. And actually the self-evaluating of keywords is understood as a kind
> of binding.
>
> But how about something else. The following works in CLISP:
>
> [3]> (defun t () 42)
> T
> [4]> (t)
> 42
>
> Now, that's some nasty Lisp p0rn.

Both have the same problem: if done by two different bodies of code,
you have a collision, and only one fdefinition will be effective.

Kaz Kylheku

unread,
Sep 6, 2012, 8:03:41 PM9/6/12
to
On 2012-09-06, Pascal J. Bourguignon <p...@informatimago.com> wrote:
> Kaz Kylheku <k...@kylheku.com> writes:
>> But how about something else. The following works in CLISP:
>>
>> [3]> (defun t () 42)
>> T
>> [4]> (t)
>> 42
>>
>> Now, that's some nasty Lisp p0rn.
>
> Both have the same problem: if done by two different bodies of code,
> you have a collision, and only one fdefinition will be effective.

Of course. There can only be one One True Function. :)

D Herring

unread,
Sep 7, 2012, 1:26:33 AM9/7/12
to
On 09/06/2012 05:01 PM, Kaz Kylheku wrote:

> But how about something else. The following works in CLISP:
>
> [3]> (defun t () 42)
> T
> [4]> (t)
> 42
>
> Now, that's some nasty Lisp p0rn.

Technically, the standard prohibits user code from modifying symbols
in the CL package. Some implementations squawk when you try this.

For real entertainment, try something like changing the symbol-value
of nil.

- Daniel
0 new messages