Hi Tomas,

> is there a function to look up an interned symbol?
> 'intern' does not seem to be doing that:

In fact, 'intern' is intended for that.

> This behaviour seems a bit strange to me.  I would expect (pack
> (intern "NIL")) to return NIL...

You are right. This is a bug in 'intern'.

When 'intern' encounters a string like "abc", it searches for an
internal symbol with that name, and returns it if it is found, or
interns it. In both cases an internal symbol 'abc' is returned.

'NIL', however, is a special symbol which is recognized by the reader.
In 32bit PicoLisp, there is no symbol with a name "NIL" interned, so
that when

   : (intern "NIL")

is executed, a new symbol with that name is interned. Though it looks
like the original 'NIL', it is a different symbol, which is neither
"false" nor matches an empty list etc. This will create chaos during
further execution.

BTW, this is different in MiniPicoLisp and in 64bit PicoLisp, where
'NIL' is interned with the name "NIL" like any other symbol.

   32bit PicoLisp
      : (not (intern "NIL"))
      -> NIL

   MiniPicoLisp or 64bit PicoLisp
      : (not (intern "NIL"))
      -> T

The question is: What is the "correct" way?

The same problem applies to other symbols as well, when they have
names with special characters. For example:

   : (intern "123")
   -> 123
   : (+ @ 7)       
   123 -- Number expected

I will fix 'intern' in 32bit PicoLisp too, so that it recognizes "NIL".
But I'm not sure about other patterns.

- Alex
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to