a bug?

For the Compleat Fan
Locked
LoveVirus
Posts: 4
Joined: Fri Dec 13, 2013 1:25 pm

a bug?

Post by LoveVirus »

I come from china,my english is poor,I like lisp,like newlisp too!But find some bug.
eg:
(define (fac n) (if (= n 1) 1 (* n (fac (- n 1)))))
(fac 30)
-8764578968847253504
This result is fault!

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: a bug?

Post by Lutz »

The function overflows 64-bit integers. Call with a big integer number (the L suffix) and it will return the correct result:

Code: Select all

> (fac 30L)
265252859812191058636308480000000L
see also here: http://www.newlisp.org/downloads/newlis ... ml#big_int

LoveVirus
Posts: 4
Joined: Fri Dec 13, 2013 1:25 pm

Re: a bug?

Post by LoveVirus »

Lutz,Thanks for your help!

I have some other questions,in this topic have some Differences to Other LISPs.
http://www.newlisp.org/index.cgi?page=D ... ther_LISPs
But in my idea,

1.nil<=>(),(first '())=>(rest '())=>()=>nil,Rather than some of the results newlisp now, I feel somewhat inappropriate in concept newlisp
2 In fact, I do not agree with nil said false, preferably with separate true and false, false estimates with nil to indicate which language is to learn c 0 => false practice it
3 I have an idea, is it possible to do a mini lisp kernel, the kernel which includes only a few elements of the basic axioms of lisp, the other by the library to achieve, the kernel should be stable not easily change , and the library can be updated frequently

Of course, I was a junior lisp enthusiasts, some ideas may be more naive, but still hope you can give some advice to see these ideas feasible.

Note: This is my google automatic translation, grammar and some may question, but this is the general meaning

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: a bug?

Post by Lutz »

The traditional axioms of LISP are not the foundations of newLISP. You will see that in the big picture of things, when using newLISP, its new definitions of nil and () and first and rest work out fine when using the language.

The way traditional LISP defines nil, the empty list () and the behavior of car, cdr and cons have much to do with the way LISP was implemented back then on a low hardware level. That does not mean, that these definitions are the only possible way to work with lists and lambda expressions in a functional language.

Locked