Hacker News new | ask | show | jobs
by aidenn0 2755 days ago
I still fail to see how methods are not data in the general sense, but while trying to answer my own question, it seems that "data" in clojure means roughly "Either an atomic type[1] or a collection"

1: an "atom" in clojure is not what it is in traditional lisp lingo; is there a name in clojure for type that is roughly the union of: symbol, number, character, boolean ? perhaps "primitive"?

3 comments

This concept is pretty subtle. Rich Hickey does a great job at explaining it (as always) in "Are We There Yet?"[1]. He deconstructs objects into state (attributes) and behavior (methods), and then uses values (or data) to represent state, and functions to represent behavior. Give that a watch a couple of times to get a better handle on what all this means from the Clojure perspective.

[edit] To answer your other question, a value that isn't a collection in Clojure is called a scalar.

1: https://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hi...

Oh, so in TFA, Stuart is using the term "data" to mean "Value" in the sense that Rich talks about (Are We There Yet is only one of of many of his talks about values (I think he had one called something like The Value of Values).
Within Clojure almost all data is directly serializable to data literals. Java objects don't have this property directly and are guaranteed to exposed everything via methods. Datafy and Nav just give Clojure the power to codify your observations. You're right for the most part, this is just the tools for interop (and a bunch of cool stuff you can build on top of it).
Perhaps “value”? The language is data-oriented, and everything you mentioned in [1] except for “symbol” easily falls within that. In Clojure, a symbol always evaluates to a specific value too, so it seems like a good fit.

A Clojure atom is one of the few types that is not immutable, but the way it is updated is pretty strictly enforced by the language, and references to it at any given point in time are still immutable.

I don’t have any insight into your broader question.