On Aug 13, 2009, at 3:35 PM, Bradbev wrote:

>
> What is the main point of reader macros?  Is it so you can define your
> own short-hand syntax, or is it the ability to get more direct access
> to the reader?
> If it is the first point, then I'd be happy to not have them - to me
> shorthand doesn't buy much.
> If it is the second point then why not simply have the reader pipe raw
> text into a reader macro?
> Ie, usage would be like
> (def-reader-macro pass-through [raw-string]
>  (read-string raw-string))
>
> Usage would be (pass-through (+ 1 2)).  The pass-through call would be
> given "(+ 1 2)" in the raw-string argument and must return a value
> that can be eval'd.
>
> More complex "reader" macros could be (infix x + y + z / 3).


I think you can already do that with regular macros.

I'm under the impression reader macros usually have to be prefixed  
with #, like #(foo %) which expands to (fn [x] (foo x)) or something  
like that. I can't find the common lisp units package I was talking  
about, but if it were perfect it would have worked something like Frink:

   http://futureboy.us/frinkdocs/

So you could do something like (+ 1m 2m) and have it give you back 3m,  
and if you did (/ 10m 5s) it would give you back 2m/s, and blow up if  
you tried to do (+ 1m 2m^2).

It would be difficult to do such a thing unobtrusively without a  
reader macro.

The other project I had experience with, CL-SQL, I think having a  
reader macro was sort of an abuse; it doesn't matter much if you have  
to put a call around your SQL or even stick it in quotes. Especially  
because it's unclear to me what value you should get from reading an  
SQL expression other than a string, unless it's going to blow up when  
you have a syntax error at compile time, but as an abstraction layer  
it certainly didn't have enough information to do that correctly at  
compile time.

—
Daniel Lyons


--~--~---------~--~----~------------~-------~--~----~
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