Hi If the sexp will not be evaluated from clojure code, why aren't you using a function to generate the code instead of a macro. That avoids the namespace resolution.
If you want to go with macros, there is a trick to turn namespace resolution of. just unquote like this @': Am 03.09.2012 01:07 schrieb "Don Jackson" <cloj...@clark-communications.com >: > > > Hello, > > I want to generate non-Clojure s-expressions in Clojure code, with a nice templating format (like syntax-quote provides), BUT with the option of providing my own methods/functions for > resolving/processing symbols, and the ability to provide my own methods/functions for evaluating syntax-quote "escapes", e.g. ~, @. > > Is there anything out there I can use? > > Here is some background: > > I have been playing around with generating SUO-KIF from Clojure code. > >> ontolog.cim3.net/file/resource/reference/SIGMA-kee/suo-kif.pdf >> > Here is an example SUO-KIF form: > > (=> > (instance ?COMPANY Coffeeshop) > (exists (?SERVICE ?BEVERAGE) > (and > (instance ?SERVICE CommercialService) > (agent ?SERVICE ?COMPANY) > (instance ?SERVICE Selling) > (patient ?SERVICE ?BEVERAGE) > (instance ?BEVERAGE Coffee)))) > > I'd like to generate the above via a Clojure macro/function that would be called like this: > >> (sells Coffeeshop Coffee) >> > By defining sells something like this: > > (defmacro-like-thing sells [kind-of-store product] > `(=> > (instance ?COMPANY ~kind-of-store) > (exists (?SERVICE ?PRODUCT)) > … > )) >> >> > My initial thought was this was going to be completely trivial, and I'd be done in 30 minutes maximum > and it is easy to generate something right away, but I am not at all happy > with the result, especially what the Clojure code "templates" look like. > > It would be really nice if the resulting template would look very close to the resulting output, so that users of this tool (Ontologists, not programmers) > could easily see/specify the templates. > > My first thought was that I would use Clojure macros and syntax-quote to generate the SUO-KIF s-expressions. > To my way of thinking, syntax-quote is a very nice s-exp templating tool, what could be easier? > I quickly re-learned that macros are a really about generating Clojure, at read time, that is then eval'ed. > Two issues with that: > 1) symbols in my template specification are resolved/namespace-qualified by syntax-quote, which is not what I want at all. > 2) I don't want the resulting s-expression to be eval'ed by Clojure. I can work around that by having the the macro return (quote s-exp), I guess. > > I then tried using syntax-quote within a Clojure function, but again, syntax-quote is resolving/namespace-qualifying the symbols, > and of course, a function's arguments are always evaluated on the way in, which leads to tedious and unpleasant quoting of SUO-KIF symbols. > > I'd welcome any thoughts/pointers about how best to approach this. > > Don > > > > -- > 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 -- 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