add-memberalign-toparrow-leftarrow-rightbellblockcalendarcamerachatchevron-leftchevron-rightchevron-small-downchevron-upcircle-with-crosscomposecrossfacebookflagfolderglobegoogleimagesinstagramkeylocation-pinmedalmoremuplabelShape 3 + Rectangle 1pagepersonpluspollsImported LayersImported LayersImported LayersshieldstartwitterwinbackClosewinbackCompletewinbackDiscountyahoo

Austin Clojure Meetup Message Board › Reader Literals and Macros

Reader Literals and Macros

Wayne R.
user 5389114
Round Rock, TX
Post #: 5
I was thinking more about this, and I don't see a benefit to using a macro as a data literal handler. The reason I heard for wanting this was to avoid evaluation of the arguments. However, this is all happening at read time and the arguments handed to the specified handler are only read -- not evaluated.

This means the function you provide is very much like a macro already. It's passed a read form which it can then transform into a different form which may or may not be evaluated later.

Here's a pointless demonstration :)

;below (+ 1 2) is eval'd before 'type' is called.
user> (type (+ 1 2))

;below (+ 1 2) is read, but not eval'd yet when 'type' is called.
user> (binding [*data-readers* {'type #'clojure.core/type}] (read-string "#type (+ 1 2)"))

Next month's macro discussion will almost certainly have to help us tease apart the R and E in REPL :)

Norman R.
Austin, TX
Post #: 29
Right. The macro would get the exact same quoted form as the reader function:

user> ((juxt type count) '(+ 1 2))
[clojure.lang.PersistentList 3]
user> (defmacro useless-macro [expr] ((juxt type count) expr))
user> (useless-macro (+ 1 2))
[clojure.lang.PersistentList 3]

I still don't understand the entire read/eval process. Depending on what direction John goes with his macro talk, I could definitely see a presentation that deconstructed the REPL. I still can get confused by things, especially around namespaces. Maybe we can put this on the topic wish list...
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy