Vinzent <ru.vinz...@gmail.com> writes:

>> I'd still prefer a more general plain-macro version for conditional
>> compilation with arbitrary tests instead of hardcoded platform and
>> version keys.
>
> I agree, although nothing prevents us from something like :condition
> (some-expr) being evaluating for such complex cases. By the way, do
> you have any clue why in Common Lisp they use #+ #- instead of macro
> approach, which seems a way more powerful?

Reader macros are quite common in CL, and they are short and handy when
you use them on individual forms inside functions, i.e., when you don't
split specifics into separate files.  And of course, CL implementations
are usually not hosted on some other VMs, so interop with host platforms
doesn't occur.  You rather deal with little things like clisp
interpreting the common lisp spec about file system access slightly
different than SBCL, or with non-standardized extension libs.

With respect to plain macros: that's almost trivial to do in both CL and
Clojure, and I'm sure that's frequently done here and there.  For
example, that's a quick and dirty macro I'm using somewhere in my code:

--8<---------------cut here---------------start------------->8---
(defmacro compile-if
  "Evaluate `exp` and if it returns logical true and doesn't error, expand to
  `then`.  Else expand to `else`.  Example:

  (compile-if (Class/forName \"java.util.concurrent.ForkJoinTask\")
    (do-cool-stuff-with-fork-join)
    (fall-back-to-executor-services))"
  [exp then else]
  (if (try (eval exp)
           (catch Throwable _ false))
    `(do ~then)
    `(do ~else)))
--8<---------------cut here---------------end--------------->8---

It would just be nice if there was a standard facility for doing stuff
like that, for example in the form of a platform namespace with a
conditional compilation macro plus various commonly needed predicates
that can be used as test expressions.  (I would not object to a reader
macro in addition.)

Bye,
Tassilo

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