bug of newLISP v.10.6.0

Q&A's, tips, howto's

bug of newLISP v.10.6.0

Postby Jian Leng » Sat Jan 24, 2015 2:30 am

Hi NewLisper,

I found the predicate number? has a bug.
when input number? 2323abc, it will return
true. So I think its a bug.

David
Jian Leng
 
Posts: 2
Joined: Sat Jan 24, 2015 2:25 am

Re: bug of newLISP v.10.6.0

Postby rickyboy » Sat Jan 24, 2015 3:47 am

It's not a bug. 2323 is a number.
(λx. x x) (λx. x x)
rickyboy
 
Posts: 594
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: bug of newLISP v.10.6.0

Postby rickyboy » Sat Jan 24, 2015 3:57 am

:)

The TLDR is that newlisp parses 2323abc as two atoms, namely the integer 2323 and the symbol abc. Finally, the primitive number? only reads its first argument (and ignores any additional arguments). So saying

Code: Select all
(symbol? 2323abc)

is the same as saying

Code: Select all
(symbol? 2323 abc)
(λx. x x) (λx. x x)
rickyboy
 
Posts: 594
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: bug of newLISP v.10.6.0

Postby Jian Leng » Sat Jan 24, 2015 5:14 am

I see. Thanks a lot.

David
Jian Leng
 
Posts: 2
Joined: Sat Jan 24, 2015 2:25 am

Re: bug of newLISP v.10.6.0

Postby xytroxon » Sat Jan 24, 2015 8:24 am

That is not always a good "feature"...
Code: Select all
> (setq abc 123OX 456)
456
> abc
123   ; abc  should be 1230
> X
nil   ; X should be 456

In the dyslexic process of anticipating to shift to type the "X" key, I hit the "O" (oh) key instead of the "0" (zero) key. (aka "toushie" typing ;o) Parser missed an error it might/should have caught by enforcing whitespace separation at the end of a numerical value.

Code: Select all
> OX
> 456 ; There it is!!!


-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976
xytroxon
 
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm

Re: bug of newLISP v.10.6.0

Postby Lutz » Sun Jan 25, 2015 2:53 pm

The way newLISP parses numbers is practical when parsing normal text. Numbers are often followed by unit identifiers, e.g.:

Code: Select all
> (parse "length 100cm")
("length" "100" "cm")
> (parse "temperature is 100°")
("temperature" "is" "100" "°")
> (parse "weight is 10lbs")
("weight" "is" "10" "lbs")
> (parse "100$")
("100" "$")
> (parse "100¥")
("100" "¥")
> (parse "100€")
("100" "€")
> (parse "100e3€")
("100e3" "€")
> 100e3
100000
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: bug of newLISP v.10.6.0

Postby xytroxon » Mon Jan 26, 2015 7:48 am

Please add a few of those examples to the parse section of the newLISP manual.

We humans are not well-versed in these advanced logic designs of the Krell*...

-- xytroxon

*http://en.wikipedia.org/wiki/Krell
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976
xytroxon
 
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron