Are two empty lists guaranteed to be 'eq?' in Racket?

Viewed 48

Is (eq? '() '()) guaranteed to be true in Racket?

If not mistaken, two empty lists are guaranteed to be eq? in R7RS, but I want to know if Racket also provides such a guarantee.

I have read the documentation, but I couldn't find the answer.

1 Answers

Yes. The behaviour of eq? more or less follows eq? from Scheme.

The documentation on eq? could be clearer though. The documentation on lists has the following to say:

A list is recursively defined: it is either the constant null, or it is a pair whose second value is a list.

So the empty list is a constant - which means it is unique.

Related