Maintenance release newLISP v.10.1.5

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

Maintenance release newLISP v.10.1.5

Post by Lutz »

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

Release notes: http://www.newlisp.org/downloads/newLIS ... lease.html
Downloads: http://www.newlisp.org/index.cgi?page=Downloads

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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

Code: Select all

(div 0 -1) => -0
also 0.01e-200 is not zero, but:

Code: Select all

(zero? 1e-324) => true

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

int

Post by newdep »

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
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

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

Code: Select all

(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:

Code: Select all

(int "08")
;-> 0
:)

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

Post by Lutz »

... 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:

Code: Select all

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

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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

Code: Select all

#ifdef READLINE
#include <readline/readline.h>
#endif
instead of this ->

Code: Select all

#ifdef READLINE
#include <readline/readline.h>
#include <readline/history.h>
#endif
when using this makefile entry ->

Code: Select all

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 ->

Code: Select all

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))

Locked