Arc Forumnew | comments | leaders | submitlogin
3 points by absz 6278 days ago | link | parent

It's intentional, although it may violate your expectations. In Arc, the empty list is denoted nil, but can also be written '() and (). (You can check this by typing (is nil '()) and (is nil ()) into the REPL; both will return t for true.) Reversing the empty list should (naturally) result in the empty list, so it seems like you were expecting (rev '()) --> '(). However, even though you input the empty list in the Scheme manner, it was output as nil, in the CL and Arc manner. So if you were expecting the reversal of the empty list to be the empty list, it does what you would expect. If you were expecting '() to be the preferred syntax for the empty list, it doesn't.


2 points by mdh 6278 days ago | link

My apologies, I was foolish in that I did not consider that '() evals to nil prior to the evaluation of rev. (rev nil) --> nil - this now makes more sense.

A couple more observations on this point:

(list) --> ()

((fn nil 'a)) --> a

(type (list)) --> sym

Is there any valid use of the '() syntax other than zero parameter declarations in functions? It would appear that in arc, one should embrace nil.

-----

5 points by sacado 6278 days ago | link

Personally, I use '() when I mean "the empty list" and nil when I mean either "the false boolean" or "no value yet". It is just a matter of readability, since they're both as long to type ;)

-----

4 points by bogomipz 6277 days ago | link

Simply () works too, and is more than 33% shorter ;)

The following shows four ways to express the empty list, and proves that they mean the same in Arc. What's a little peculiar, however, is that one gets printed differently;

  arc> (is () '() nil 'nil)
  t
  arc> ()
  ()
  arc> '()
  nil
  arc>

-----

1 point by absz 6277 days ago | link

In Arc, they are equivalent, so it doesn't really matter. I think pg would like us all to use nil everywhere, but (obviously) that's not being enforced. Nevertheless, based on arc.arc, I think "embracing nil" is probably the best idea.

-----