views:

218

answers:

5

Common LISP and Emacs LISP have the atom type predicate. Scheme and Clojure don't have it. http://hyperpolyglot.wikidot.com/lisp

Is there a design reason for this - or is it just not an essential function to include in the API?

+5  A: 

In the entire IronScheme standard libraries which implement R6RS, I never needed such a function.

In summary:

  • It is useless
  • It is easy enough to write if you need it

Which pretty much follows Scheme's minimalistic approach.

leppie
+10  A: 

In Clojure, the function isn't so important because Clojure emphasizes various other types of (immutable) data structures rather than focusing on cons cells / lists.

It could also cause confusion. How would you expect this function to behave when given a hashmap, a set or a vector for example? Or a Java object that represents some complex mutable data structure?

Also the name "atom" is used for something completely different - it's one of Clojure's core concurrency mechanisms to manage shared, synchronous, independent state.

mikera
+7  A: 

Clojure has the coll? (collection?) function, which is (sort of) the inverse of atom?.

Stuart Sierra
A: 

It's a trivial function:

(defun atom (x)
   (not (consp x)))

It is used in list processing, when the Lisp dialect uses conses to build lists. There are some 'Lisps' for which this is not the case or not central.

Rainer Joswig
A: 

In Scheme anything that is not a pair is an atom. As Scheme already defines the predicate pair?, the atom? predicate is not needed, as it is so trivial to define:

(define (atom? s)
    (not (pair? s)))
Vijay Mathew