Vinzent <[email protected]> writes:
> First thing which comes to mind is to use metadata for this purpose.
> Something like
>
> (defn ^{:platform :jvm} to-string [x] ...)
I don't think that's too practical. The reader sees the metadata only
after it already started to read the form it should then ignore, if the
platform doesn't match.
> Another option is to use reader macros, like in Common Lisp:
>
> #+ :jvm (defn to-string ...)
Yet another option is to use plain macros, and arbitrary test
expressions instead of just keywords. For example, I have some jvm
clojure code where I use the ForkJoin classes if available and fall back
to executor services if not. One could consider a clojure.platform
namespace with standard, frequently used predicates.
Something along the lines of:
(cond-compile
(platform-jvm? ">=1.7.0") ...
(platform-jvm?) ...
(platform-clr?) ...
:else (throw (Exception.
(format "Sorry, frobnification not supported on %s" *platform*))))
Bye,
Tassilo
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en