Maintenance release newLISP v.10.1.5

Started by Lutz, September 15, 2009, 06:17:40 AM

Previous topic - Next topic

Lutz

• This maintenance release contains improvements and fixes for time related functions.



Release notes: http://www.newlisp.org/downloads/newLISP-10.1-Release.html">http://www.newlisp.org/downloads/newLIS ... lease.html">http://www.newlisp.org/downloads/newLISP-10.1-Release.html

Downloads: http://www.newlisp.org/index.cgi?page=Downloads">http://www.newlisp.org/index.cgi?page=Downloads

newdep

#1
From the perspective of NaN and INF



Should (div 0 -1) be fixed to 0 ?



From what I know of math is that 0 is 0 and it doesnt have a sign.



And because were are dealing with Float here it doesnt make sence

if its a 0.01e-200 or a -0... a zero is a zero or not ?



Just asking..

because (zero? -0) is still true but a (zero? -0.01e-200) is nil



Norman.
-- (define? (Cornflakes))

Lutz

#2
As of the IEEE 754 standard for floating point arithmetic, the 0 should be signed:


(div 0 -1) => -0

also 0.01e-200 is not zero, but:


(zero? 1e-324) => true

newdep

int
#3
Newlisp doesnt have a String to Int/float conversion, right?

..Im just checking if i understand it correcty..



(int "123abc123" "not a number")

>123



(int "abc123")

>nil



actualy 'float does the same..seems they only care about the first part they find,

thats actualy not what the manual says about these..(yes it does...but...)



So to actualy convert a string to int you need to clean the string from none-numbers

first, save the + - . , e signs from it then convert to int or float and then check if its a int

or float..





So actualy you can never assume that a string check again interger? is indeed

an integer?



(integer? (int "1imaninteger")

> true



Where i would expect actualy nil.. but that because of the behaviour of (int)

PS: int is not listed in the rev 5 manual (left frame) (sorry it is! at the end ;-)

PPS: integer is still accepted in 10.1.5



*edited*
-- (define? (Cornflakes))

cormullion

#4
Perhaps you should use int's default return value feature...


(int x 0)

which will always be an integer...



I think converting strings to integers is always going to be a job you need to take care with, otherwise your program will fail in strange and wonderful ways:


(int "08")
;-> 0


 :)

Lutz

#5
... demonstrating the most occurring unintended misuse of 'int': the 0 as first digit signals an octal number (0 to 7).



The safest way is, to always supply a default/error value/behavior and expected conversion base:


(int "08" (throw-error "cannot convert") 10)

newdep

#6
newlisp on slackware 10.1.5

needs this in newlisp.c line +/- 30 ->

#ifdef READLINE
#include <readline/readline.h>
#endif


instead of this ->

#ifdef READLINE
#include <readline/readline.h>
#include <readline/history.h>
#endif

when using this makefile entry ->

CFLAGS = -m32 -Wall -pedantic -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DREADLINE -DLINUX

$(CC) $(OBJS) -m32 -g -lm -ldl -lreadline -ltermcap -o newlisp #slackware




If the <readline/history.h> is not removed I get this result ->
gcc -m32 -Wall -pedantic -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DREADLINE -DLINUX newlisp.c
In file included from newlisp.c:30:
/usr/include/readline/history.h:46: error: redefinition of 'struct _hist_entry'
/usr/include/readline/history.h:83: error: conflicting types for 'add_history'
/usr/local/include/readline/readline.h:94: error: previous declaration of 'add_history' was here
make: *** [newlisp.o] Error 1
-- (define? (Cornflakes))