Is true symbol?

Pondering the philosophy behind the language

Is true symbol?

Postby Kazimir Majorinc » Wed Jun 25, 2014 5:34 am

> (symbol? 'true)
true
> (symbol? (eval 'true))
nil

> (= 'true (eval 'true))
true


Is it bug or feature? I'd expect that true is always symbol.
Kazimir Majorinc
 
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia

Re: Is true symbol?

Postby hugh.jf.chen » Wed Jun 25, 2014 6:34 am

True is a symbol. (eval 'true) is a expression. Since symbols are also expressions,so the = return true. I feel make sense.
hugh.jf.chen
 
Posts: 7
Joined: Sun Aug 11, 2013 3:50 pm

Re: Is true symbol?

Postby Lutz » Wed Jun 25, 2014 1:01 pm

In newLISP the writing for the symbols true and nil and the boolean values true and nil is the same. Because of this, the symbols should also equal their boolean values:

Code: Select all
> (set 'lst (list true 'true nil 'nil))
(true true nil nil) ; symbols and boolean values are indistinguishable to the eye

> (map symbol? lst)
(nil true nil true) ; lst contains both, boolean values and symbols

> (map nil? lst)
(nil nil true true) ; both equal the same boolean value

> (map true? lst)
(true true nil nil) ; both equal the same boolean value
Lutz
 
Posts: 5261
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Is true symbol?

Postby rickyboy » Wed Jun 25, 2014 2:53 pm

At least you can't do this (by default).

Code: Select all
> (let (true nil) true)

ERR: symbol is protected in function let : true
> (let (true 'maybe) true)

ERR: symbol is protected in function let : true
>

:)))))

Hello, Kazimir! Good to hear from you again.
(λx. x x) (λx. x x)
rickyboy
 
Posts: 557
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: Is true symbol?

Postby rickyboy » Wed Jun 25, 2014 3:26 pm

Here are the ways two other languages treat this issue.

In Common Lisp, apparently T and NIL are also symbols.

Code: Select all
$ /opt/ccl/wx86cl64.exe
Welcome to Clozure Common Lisp Version 1.9-r15765  (WindowsX8664)!
? (symbolp t)
T
? (symbolp 't)
T
? (symbolp nil)
T
? (symbolp 'nil)
T
?

Not so, in this implementation of Scheme.

Code: Select all
$ /opt/Racket/mzscheme
Welcome to Racket v5.3.5.
> (symbol? #t)
#f
> (symbol? '#t)
#f
> (boolean? #t)
#t
> (boolean? '#t)
#t
> (boolean? #f)
#t
>

Apparently, in Scheme, both #t and #f belong to a type (informal?) called boolean and they are NOT symbols (i.e. do not belong to the symbol type), although they sort of look like self-evaluating symbols. Interesting.

In newLISP, true and nil are self-evaluating, but they are not symbols. At least they are not symbols strictly speaking (cf. Lutz's example true versus 'true, where the latter is a symbol). This situation is more in line with the Scheme design choice, except where its boolean value #t is not a symbol when quoted, but newLISP's true is. Again, interesting.
(λx. x x) (λx. x x)
rickyboy
 
Posts: 557
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia


Return to Whither newLISP?

Who is online

Users browsing this forum: No registered users and 1 guest