a bug?

Started by LoveVirus, December 13, 2013, 05:37:38 AM

Previous topic - Next topic

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

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



> (fac 30L)
265252859812191058636308480000000L


see also here: http://www.newlisp.org/downloads/newlisp_manual.html#big_int">http://www.newlisp.org/downloads/newlis ... ml#big_int">http://www.newlisp.org/downloads/newlisp_manual.html#big_int

LoveVirus

#2
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=Differences_to_Other_LISPs">http://www.newlisp.org/index.cgi?page=D ... ther_LISPs">http://www.newlisp.org/index.cgi?page=Differences_to_Other_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

#3
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.