Arc Forumnew | comments | leaders | submitlogin
Arc - t and nil
2 points by heiz 3833 days ago | 2 comments
Hi! Why t and nil are blocked for rebinding? I suppose it is enough that nil <=> '() and t is (not nil).

4 points by rocketnia 3833 days ago | link

This is a pretty popular topic.

The fact that 't can't be rebound is a bit ugly. Its only purpose is to be an arbitrary non-nil value. It doesn't need to be constant just to keep people from breaking things, just like 'car and 'cdr don't need to be constants.

The one rationale I can think of is that code might assume 't is bound to the symbol 't and use the symbol instead of the current value of the variable. However, that only makes a difference when checking whether something is 't, and things should generally be compared to nil instead.

As for rebinding nil, that's a bit worse. It's supposed to be considered identical to (), even on a reader level. In particular, (a b c) and (a b c . nil) are both (a . (b . (c . ()))), so the following are equivalent:

  ; Accept exactly two arguments, ignore them, and return nil.
  (def foo (bar baz)
  (def foo (bar baz . nil)
But the following means something totally different:

  ; Accept two or more arguments, ignore the first two, and return the
  ; rest as a list.
  (def foo (bar baz . qux)
To make nil into a regular variable, we'd have to change the varargs syntax to avoid ambiguity.

t is (not nil).

In Arc, that would be (no nil). ^_^


1 point by heiz 3832 days ago | link

Thanks for your reply. I think this situation is a bit confusing. I hope in next arc releases it will be revised.