Arc Forumnew | comments | leaders | submitlogin
Question on '() and nil in ac.scm
6 points by nlavine 6157 days ago | 5 comments
In arc, it seems that '() and nil are equivalent. (Specifically, '() evaluates to nil.) Searching through arc.arc, it looks like people just use nil and ignore the existence of '(). However, ac.scm makes a big deal of the difference between the symbol 'nil and the empty list '(). Can we just do

  (define nil '())?
This would let us redefine the other functions in cleaner, simpler ways, and I don't think it would change semantics at all.

(For instance,

  (define (ar-false? x)
    (and x (not (null? x)))).
And all of the list-nilling functions would be unnecessary.)


4 points by pau 6157 days ago | link

I don't think it is so easy. The problem is that it is not the contents of 'nil' that you should set to '(), but the symbol itself (which you quote):

  > (define nil '())
  > (eqv? '() 'nil)
  #f

-----

4 points by nlavine 6157 days ago | link

You're right, this wouldn't work with the current ac.scm. However, if we stop treating the symbol 'nil specially and just let it be a normal variable lookup, then I think everything will work.

The only hard bit, actually, will be making it output things using 'nil instead of '(), but making a fix like that, that's isolated in one small part of the program, seems like a small price to pay for making the main arc compiler sleeker and faster (oh, and the generated code, too).

-----

2 points by kennytilton 6157 days ago | link

I do not know (literally! I do CL, not Scheme) if that would work, but it is a bit of a religious issue dividing the Lisp communities. Indeed, this is one of the reasons I am even looking at Arc, that and that mac works like CL defmacro. And fwiw, those two issues were highlighted by pg as things differentiating Arc and Scheme. Not sure if I am adding anything to the debate, but I get the feeling it either would not work or it would freak out any Schemer finding it in ac.scm. :) I guess another thought might be not to get too caught up in ac.scm since it is implementation and might disappear and become <gasp> an Arc/C or Arc/CL compiler or something.

-----

3 points by nlavine 6157 days ago | link

Hmm. On further investigation, this solves one of the two problems. The other one is that '() and #f are still different Scheme objects, so certain functions would have to stay. But I think this could still tighten up the Scheme code somewhat.

-----

1 point by sacado 6157 days ago | link

at first sight, quite a good idea...

-----