January 2018

S M T W T F S
  123456
78910111213
14151617181920
21222324252627
28293031   

Style Credit

Expand Cut Tags

No cut tags
Friday, February 23rd, 2007 10:55 am
pozorvlak@delirium:~> clisp
  i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
  I I I I I I I      8     8   8           8     8     o  8    8
  I  \ `+' /  I      8         8           8     8        8    8
   \  `-+-'  /       8         8           8      ooooo   8oooo
    `-__|__-'        8         8           8           8  8
        |            8     o   8           8     o     8  8
  ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2006

[1]> (defun car (x) (cdr x))

** - Continuable Error
DEFUN/DEFMACRO(CAR): # is locked
If you continue (by typing 'continue'): Ignore the lock and proceed
The following restarts are also available:
ABORT          :R1      ABORT
Break 1 [2]> continue
WARNING: DEFUN/DEFMACRO: redefining function CAR in top-level, was defined in
         C
CAR
[3]> (car '(3 4))
(4)
[4]> (defun defun (x) (+ 3 x))
DEFUN
[5]> (defun 7)
10

Bad. Ass.

[Those of you who don't speak Lisp may find a measure of enlightenment here. Should be reasonably accessible.]
Friday, February 23rd, 2007 11:01 am (UTC)
(defun defun (x) (string-right-trim "fun" x))
Friday, February 23rd, 2007 11:33 am (UTC)
*groan*

You know, I had no suspicion that you'd be able to make a joke in valid Common Lisp... clearly, you have hidden depths that I know nothing about. Besides the hidden depths that I already knew about, obviously.
Friday, February 23rd, 2007 05:11 pm (UTC)
Could you possible give an explanation for us ignorami at 5:00 on a friday night...
Friday, February 23rd, 2007 05:24 pm (UTC)
A joke explained is a joke ruined, young man!

It's not that funny either
Sunday, February 25th, 2007 01:25 pm (UTC)
[1]> (string-right-trim "fun" "Hey, this is fun")
"Hey, this is "
Friday, February 23rd, 2007 11:34 am (UTC)
I didn't find much enlightenment there I'm afraid. But I did finally figure out what car and defun mean. And giggled.
Friday, February 23rd, 2007 12:36 pm (UTC)
I think it's interesting to note that defun is not implemented in C, so presumably clisp's authors have taken the idea of writing Lisp in itself seriously...
Friday, February 23rd, 2007 12:01 pm (UTC)
Bad. Ass.


I guess now might be a good time to try liskell then :) Not with actual docs and everything! :)
Friday, February 23rd, 2007 12:01 pm (UTC)
Sigh - s/Not/Now/
Friday, February 23rd, 2007 12:35 pm (UTC)
Actual docs? For a Haskell library? You're kidding, right? :-)

At the moment, I'm coding Haskell with ghci open in one window, my code open in another, and the Parsec code open in a third. At least one function that I've needed hasn't been mentioned in the documentation so far (and the Parsec docs are pretty good, by Haskell community standards) :-(

I've been working on my Lisp interpreter for the last couple of days (hence playing around with clisp). Lexing Lisp code is surprisingly tricky if you want to do it properly...
Friday, February 23rd, 2007 04:00 pm (UTC)
Hehe!
Friday, February 23rd, 2007 04:49 pm (UTC)
I was just wondering... What is the scope of those defuns? Can I write a library which changes the meaning of any code which thinks about using it?

I'm sure I could find this out through the docs, or by experimentation, but idle drawing room conversation on LJ seemed like a more interesting way of doing it :)
Sunday, February 25th, 2007 01:20 pm (UTC)
Hmmmm... I know you can do that in Perl (check out SVG::GD), and I see no reason why you couldn't do it in Lisp. Let's try something...
[1]> (defun wilma (x) (car x))
WILMA
[2]> (defun car (x) (cdr x))

** - Continuable Error
DEFUN/DEFMACRO(CAR): # is locked
If you continue (by typing 'continue'): Ignore the lock and proceed
The following restarts are also available:
ABORT :R1 ABORT
Break 1 [3]> continue
WARNING: DEFUN/DEFMACRO: redefining function CAR in top-level, was defined in C
CAR
[4]> (wilma '(3 4))
(4)


So it certainly redefines local functions... however, if we (compile 'wilma) before redefining car, then (wilma '(3 4)) returns 3. As to your actual question... "dunno" is the answer - I don't really understand how modules work in Common Lisp. [livejournal.com profile] stronae?
Friday, May 4th, 2007 08:44 pm (UTC)
congratulations, you have unearthed a clisp bug:
http://sourceforge.net/tracker/index.php?func=detail&aid=1713130&group_id=1355&atid=101355please

next time, plese report clisp bugs to clisp maintainers at http://clisp.cons.org/impnotes/clisp.html#bugs (note the link "How do I report bugs?" on the clisp home page).
Friday, May 4th, 2007 10:27 pm (UTC)
Really? I'd assumed it was correct behaviour - and rather cool, hence my post :-) I'm not really a Lisper, so I don't know what's expected.