Hi, I'd like to propose/put up for discussion a change to the unquote handling. I basically ran into the following problem:
I'd like to embed a DSL into my system. Using macros it should be possible to define a language, which looks like usual Clojure. Simply quote the form and pass it to a function, which knows how to handle the commands. However I hit a roadblock. Coming from Scheme, I tried the following approach. A hypothetical SQL embedding: (def x 5) (sql col1 from table1 where col2 = ~x) Or a hypothetical cljsh (inspired by scsh): (def *cmd* "/usr/bin/command") (run (~*cmd* -option 1 -another argument foo bar)) In Scheme this is done, by quoting the macros argument using the quasiquote form. In Clojure, however, this style is not possible since we are missing quasiquote. Here a short list of examples on how the different quotations work: (quote (foo ~x bar)) => Failure in Clojure. => In some Schemes: (foo (unquote x) bar), where , (aka. ~) translates to some unquote form. It just quotes everything. Also the unquote. (quasiquote (foo ~x bar)) => Not available in Clojure. => (foo 5 bar) in Scheme (syntax-quote (foo ~x bar)) => (assuming ` would have a syntax-quote form as ' does with quote) (my.ns/foo 5 maybe.some.other.ns/bar) => Not available in Scheme, AFAIK. So as you see, the above style is not possible, since in Clojure you only have the choice to be static or resolve all the symbols. If I want to use the style anyway, I have to jump through hoops and rewrite the quoted form in my handler function, be it replacing somehow marked or named symbols with values from the environment or be it renormalising all the symbols. (But what if the user injected a qualified symbol with ~?) So I came to the question of whether it is possible to include a similar quasiquote form, which does not resolve the symbols inside? It would be a philosophy of "Unquote, what the user wants to be unquoted, and leave the rest to me. I know how to handle it." And when were are at it: maybe also provide a syntax-quote, unquote and unquote-splice forms? Finally, I skipped the obvious question: Does this make sense at all? I like this way of including a sub-language. However, is it "idiomatic"? (for some definition of "idiomatic") Maybe there is already a different solution, which I just don't see at the moment. Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---