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

wishLisp new version (0.1.3.6) with Source Code

2 views
Skip to first unread message

kernm...@yahoo.fr

unread,
Sep 16, 2008, 6:27:14 PM9/16/08
to
Hello

I finally decided to release the source code of this prototype
implementation of a Lisp Interpreter hoping it may serve as an example
(or counter example maybe) for students and "lifetime students" who
are curious about how a Lisp interpreter could be implemented

Slobodan Blazeski

unread,
Sep 17, 2008, 5:03:16 AM9/17/08
to
cool thanks. it would be even nicer if you wrote what functions it
supports.

John Thingstad

unread,
Sep 17, 2008, 5:22:42 AM9/17/08
to
På Wed, 17 Sep 2008 11:03:16 +0200, skrev Slobodan Blazeski
<slobodan...@gmail.com>:

> cool thanks. it would be even nicer if you wrote what functions it
> supports.

www.wishlisp.com

--------------
John Thingstad

kernm...@yahoo.fr

unread,
Sep 17, 2008, 9:35:11 AM9/17/08
to
On Sep 17, 11:03 am, Slobodan Blazeski <slobodan.blaze...@gmail.com>
wrote:

> cool thanks. it would be even nicer if you wrote what functions it
> supports.

Hello

Here is the list of 54 implemented functions (not fully support eg no
error handling):
DEFMACRO AND FUNCTIONP CAR * + LOAD IMPLEMENTED / POP QUOTE THIRD
FUNCTION LISTP FIRST FIFTH OR TRACE GETF SYMBOL-FUNCTION NOT HELP CONS
ED CDR DEFUN EVAL APPLY NULL INTEGERP EXIT PUSH SYSTEM SLEEP REVERSE -
UNTRACE SECOND QUIT MEMSTAT FORMAT FBOUNDP TEST BYE LIST PROGN CONSP
READ DEFVAR < > FOURTH IF EQL

This list is generated by wishlisp interpreter when you type
(implemented), this is described in (help)

BR
michel Kern

Matthew D Swank

unread,
Sep 17, 2008, 2:14:52 PM9/17/08
to

I also recently noticed ClearLisp (http://www.xs4all.nl/~tolenaar/
page3.html) which is another interpreter written C#. It's Common Lisp-y,
including generic functions, but has some incompatible extensions for
"convenience".

Matt

Steve Graham

unread,
Sep 17, 2008, 2:21:03 PM9/17/08
to

I know very little Lisp, but I'm getting what I think are some strange
results. Here's a copy from the shell:

> (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))
FACTORIAL
> (factorial 5)
120
> (factorial 120)
0
> (factorial 100)
0
> (factorial 50)
0
> (factorial 25)
2076180480
> (factorial 37)
0
> (factorial 31)
738197504
> (factorial 34)
0
> (factorial 33)
-2147483648
> (factorial 32)
-2147483648
> (factorial 31)
738197504
> (factorial 30)
1409286144
> (factorial 29)
-1241513984
> (factorial 28)
-1375731712
> (factorial 27)
1484783616
> (factorial 26)
-1853882368
> (factorial 25)
2076180480


Here's something similar from Clisp:
[1]> (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))
FACTORIAL
[2]> (factorial 31)
8222838654177922817725562880000000


Steve

John Thingstad

unread,
Sep 17, 2008, 3:11:30 PM9/17/08
to
På Wed, 17 Sep 2008 20:21:03 +0200, skrev Steve Graham
<solitary....@gmail.com>:

> On Sep 16, 4:27 pm, kernmic...@yahoo.fr wrote:
>> Hello
>>
>> I finally decided to release the source code of this prototype
>> implementation of a Lisp Interpreter hoping it may serve as an example
>> (or counter example maybe) for students and "lifetime students" who
>> are curious about how a Lisp interpreter could be implemented
>
> I know very little Lisp, but I'm getting what I think are some strange
> results. Here's a copy from the shell:
>
>> (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))
> FACTORIAL
>> (factorial 5)
> 120
>> (factorial 120)
> 0

...


> -1241513984
>> (factorial 28)
> -1375731712
>> (factorial 27)
> 1484783616
>> (factorial 26)
> -1853882368
>> (factorial 25)
> 2076180480
>
>
> Here's something similar from Clisp:
> [1]> (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))
> FACTORIAL
> [2]> (factorial 31)
> 8222838654177922817725562880000000
>
>
> Steve

CL-USER 40 > (rem (fact 25) (expt 2 32))
2076180480

Which looks suspiciously like the result above.

Clearly the implementation doesn't support bignum. Thus you are stuck with
the 32 bit register size.
For large multiplications C# just wraps around leading to these strange
values.

--------------
John Thingstad

Ali

unread,
Sep 17, 2008, 5:18:04 PM9/17/08
to
My one's moved on a bit too. It's slow enough to be laughable, but at
least the source is fairly small and hopefully understandable.

As with wishLisp, I hope this provides a shining example of how to
write a slow implementation of lisp in javascript.

http://code.google.com/p/lispyj/source/browse/trunk/modules/evaluation_module.js

Go to line 228 for the lisp code itself.

kernm...@yahoo.fr

unread,
Sep 19, 2008, 9:19:24 AM9/19/08
to
On Sep 17, 9:11 pm, "John Thingstad" <jpth...@online.no> wrote:
> På Wed, 17 Sep 2008 20:21:03 +0200, skrev Steve Graham  
> <solitary.wandere...@gmail.com>:
> John Thingstad- Hide quoted text -
>
> - Show quoted text -

Hello

Thanks for the feedback, I confess this "bignum" feature I was not
even aware of it and I guess it is by this kind of feature that Lisp
is beyond the more common languages like C# and Java. As this project
is enough interesting to generate feedback from people more educated
in the Lisp implementation than myself, I would like to ask where I
can find the "core functions" as many sources explain that lisp is
bootstrapped and many functions are in fact written in Lisp so where I
can fond the list of these core functions as well as the lisp source
of lisp functions written on top of the core. There is such a thing at
http://lib.store.yahoo.net/lib/paulgraham/jmc.lisp (and in the book
'ANSI Common Lisp') but I seems more an example rather than a complete
'Lisp in Lisp' source

John Thingstad

unread,
Sep 19, 2008, 11:44:37 AM9/19/08
to
På Fri, 19 Sep 2008 15:19:24 +0200, skrev <kernm...@yahoo.fr>:

>
> Hello
>
> Thanks for the feedback, I confess this "bignum" feature I was not
> even aware of it and I guess it is by this kind of feature that Lisp
> is beyond the more common languages like C# and Java.

Not exactly. Big number arithmetric is available as a seperate library.
There just isn't any check than automatically converts the number to a
bignum if it overflows. Or for that matter any check for overflow at all.

> As this project
> is enough interesting to generate feedback from people more educated
> in the Lisp implementation than myself, I would like to ask where I
> can find the "core functions" as many sources explain that lisp is
> bootstrapped and many functions are in fact written in Lisp so where I
> can fond the list of these core functions as well as the lisp source
> of lisp functions written on top of the core. There is such a thing at
> http://lib.store.yahoo.net/lib/paulgraham/jmc.lisp (and in the book
> 'ANSI Common Lisp') but I seems more an example rather than a complete
> 'Lisp in Lisp' source

Implementing a full Common Lisp is complicated. If you don't understand
and have experience with CL you will probaly get it wrong. "Lisp in small
pieces" by Quinnebeck is a 'classic' description of the workings of Lisp.
It mostly describes implementation of Scheme, but Common Lisp features are
also explained. It starts with a interprenter, then goes on to a formal
description and finally decribes how to write a compiler. Not for the
faint of heart though. Read "Structured Introduction to computer
Programming" by Abelson, Sussman, and Sussman first[1]. "Paradigms in AI
programming" by Peter Norvig also has a couple of chapters where he
implements a simple Scheme. (And it's a good book on programming Lisp in
general.)
The full soruce code of Corman CL, SBCL an Clozure CL are availabe. The
final word is "The Common Lisp Hyperspec".

[1] SICP is available online at http://mitpress.mit.edu/sicp/.There are
also some video lectures from a cource using the book at MIT at
http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/.

--------------
John Thingstad

Raffael Cavallaro

unread,
Sep 19, 2008, 12:41:26 PM9/19/08
to
On 2008-09-19 11:44:37 -0400, "John Thingstad" <jpt...@online.no> said:

> "Lisp in small pieces" by Quinnebeck is a 'classic' description of the
> workings of Lisp.


Queinnec

<http://www.cambridge.org/catalogue/catalogue.asp?isbn=0521545668>

<http://www.amazon.com/Lisp-Small-Pieces-Christian-Queinnec/dp/0521545668/ref=sr_11_1?ie=UTF8&qid=1221842397&sr=11-1>


Paul Donnelly

unread,
Sep 19, 2008, 5:22:35 PM9/19/08
to
"John Thingstad" <jpt...@online.no> writes:

Do you mean "Structure and Interpretation of Computer Programs"?

Slobodan Blazeski

unread,
Sep 22, 2008, 6:04:34 AM9/22/08
to
On Sep 19, 5:44 pm, "John Thingstad" <jpth...@online.no> wrote:

> På Fri, 19 Sep 2008 15:19:24 +0200, skrev <kernmic...@yahoo.fr>:
>
>
>
> > Hello
>
> > Thanks for the feedback, I confess this "bignum" feature I was not
> > even aware of it and I guess it is by this kind of feature that Lisp
> > is beyond the more common languages like C# and Java.
>
> Not exactly. Big number arithmetric is available as a seperate library.  
> There just isn't any check than automatically converts the number to a  
> bignum if it overflows. Or for that matter any check for overflow at all.
>
> > As this project
> > is enough interesting to generate feedback from people more educated
> > in the Lisp implementation than myself, I would like to ask where I
> > can find the "core functions" as many sources explain that lisp is
> > bootstrapped and many functions are in fact written in Lisp so where I
> > can fond the list of these core functions as well as the lisp source
> > of lisp functions written on top of the core. There is such a thing at
> >http://lib.store.yahoo.net/lib/paulgraham/jmc.lisp(and in the book

> > 'ANSI Common Lisp') but I seems more an example rather than a complete
> > 'Lisp in Lisp' source
>
> Implementing a full Common Lisp is complicated. If you don't understand  
> and have experience with CL you will probaly get it wrong. "Lisp in small  
> pieces" by Quinnebeck is a 'classic' description of the workings of Lisp.  
> It mostly describes implementation of Scheme, but Common Lisp features are  
> also explained. It starts with a interprenter, then goes on to a formal  
> description and finally decribes how to write a compiler. Not for the  
> faint of heart though. Read "Structured Introduction to computer  
> Programming" by Abelson, Sussman, and Sussman first[1]. "Paradigms in AI  
> programming" by Peter Norvig also has a couple of chapters where he  
> implements a simple Scheme. (And it's a good book on programming Lisp in  
> general.)
> The full soruce code of Corman CL, SBCL an Clozure CL are availabe. The  
> final word is "The Common Lisp Hyperspec".
>
> [1] SICP is available online athttp://mitpress.mit.edu/sicp/.Thereare  
> also some video lectures from a cource using the book at MIT at  http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/.
>
> --------------
> John Thingstad

http://library.readscheme.org/page1.html
Guy Lewis Steele, Jr. and Gerald Jay Sussman. "The Art of the
Interpreter (excellent just finishing it)
Guy Lewis Steele, Jr.. "RABBIT: A Compiler for SCHEME". (next on my
read list)

bobi

0 new messages