Try this:
> (set 'tr '( (1 "foo") (2 "bar") (3 "baz")))
((1 "foo") (2 "bar") (3 "baz"))
> (lookup nil tr)
"foo"
Unless I'm missing something, shouldn't (lookup) return nil?
By the way, I got here because I'm actually doing:
(lookup x tr)
And x can be nil.
This is fixed in the upcoming stable version 10.3.0. There is a preview here:
http://www.newlisp.org/downloads/development/inprogress/
Note, that I could only reproduce the first case in your post, not the second case where a key variable x is set to nil, where it worked correctly for me.
In upcoming 10.3.0 nil is a legitimate lookup item:
newLISP v.10.3.0 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.
> (set 'tr '( (1 "foo") (nil "bar") (3 "baz")))
((1 "foo") (nil "bar") (3 "baz"))
> (lookup nil tr)
"bar"
>
the second sublist contains nil in the lookup position.