Ken Wesson <kwess...@gmail.com> writes:

> Ah. So, like the confused situations you get with Java's mutable
> collections. Two lists are equal if they have the same contents in the
> same order -- but then you use one as a key in a hashmap, and then add
> an item to it, and boom! Clojure separates this stuff out because the
> Clojure vector's immutability makes its value stable given its
> identity. Refs and atoms and agents can encapsulate mutable state, but
> their identity (as defined by = and hash) is fixed rather than
> changing with its state.

Sort of.  Identity (in the Clojure model) is not the same concept as
equality.  Nor is it reference equality ("identical?").  The overloading
of terminology is somewhat unfortunate.

    "By identity I mean a stable logical entity associated with a series
     of different values over time." -- clojure.org/state

As Laurent mentioned the usual identities in Clojure are reference
objects: vars, atoms, refs and so on.

> And some objects (keywords and symbols) exist
> to be almost pure identity, used to label other things.

Symbols and keywords (and database IDs) aren't identities, they're
identifiers (names).

    "Note that by identities I don't mean names (I call my mother Mom,
     but you wouldn't)." -- clojure.org/state

An identifier can be resolved in some sort of context to obtain an
identity, but it is not itself that identity.

If you wrote a program with a data model like this:

  (def people {"Alice" (ref {:age 25}), "Bob" (ref {:age 17})})

Then the various objects would be:

  name: a string like "Alice"
  context: the people map
  identity: a ref
  value: the {:age XX} maps

In the vars and global environment model we have:

  name: a symbol
  context: a namespace
  identity: a var
  value: a number, list, vector, fn, string etc

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to