[plt-scheme] Syntax question (improper lists)

From: Greg Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Mon Jan 30 16:35:07 EST 2006

I'm beginning to think using dotted pairs wasn't a very good idea to
start with, but in my evaluator, I'm tagging each input expression I
read to indicate whether it is  string, list, boolean, etc. Why? I
guess ity just seemed like a good idea at the time. (Actually, I'm
using the tag as a key to dertermine what evaluator function should be
used for expressions of that type.)

It looks like this:

> (main)
>> '()
'()
Internal form: (4 quote ())
'()
>> 5
Internal form: (3 . 5)
5
>> "hello"
Internal form: (2 . hello)
"hello"
>> #t
Internal form: (1 . t)
#t
>> (exit)


(The internal form of '(), as you see is (4 quote ()) and it displays
as '(), not (). What is supposed to happen with lists is this:

> (display-value (make-list '(1 2 3)))
Internal form: (4 1 2 3)
(1 2 3)


Anyway, I'm thinking that

a) I really do need to treat '() specially and not as a list.
b) Using dotted pairs wasn't such a great idea, and I really ought to
use proper lists.

Having said that, I don't think I quite understand the rules here.
Presumably, when I read '() I get (quote ()), which prints as '(), and
if I don't quote (), I get

> (main)
>> ()
Internal form: (4)
()
>> 

which is what I intended. But in DrScheme, I get

> '()
()
> ()
()
> 

which is the behavior I was trying to emulate.

===
Gregory Woodhouse  <gregory.woodhouse at sbcglobal.net>
"All truth passes through three stages: First, it is ridiculed.
Second, it is violently opposed. Third, it is accepted as
being self-evident."
--Arthur Schopenhauer


Posted on the users mailing list.