On Thu, Apr 12, 2012 at 11:31 PM, Dave Sann <daves...@gmail.com> wrote:
> -1 for metadata
> +1 for file extensions or paths.
>
> I don't think metadata or in-file conditional compilation is the right
> tool for this.
>
> My reasons are as follows
>
> 1. I don't think it is a good idea to mix multi-platform definitions in
> one file. it gets complicated and confusing very quickly. You cant see the
> wood for the trees.
> 2. What about adding a new platform - do you edit the existing files or
> add a new one.
> 3. Different platform specifics could be maintained by different teams
> with only the port code required. Most people will not care about every
> platform.
> 4. Separating them means that you can very easily see what is platform
> specific and port. You can also easily produce separate source
> distributions if you so wish.
> 5. If you add metadata - then the complier must read the file in order to
> decide whether it needs to look process the contents or not. This will
> increase build times substantially as you add platforms.
>
> I don't know about platform versions - that could get very complicated.
>
> If following the extension route, you would also require an extension for
> generic clojure code vs jvm platform code in addition to the others.
>
> I like the idea of separate, parallel source paths:
> e.g.
>
> src/clj/blah.clj    ;; "pure" clojure
> src/jvm/blah.clj  ;; for the jvm
> src/py/blah.clj    ;; etc
> src/clr/blah.clj
> src/cljs/blah.clj
>
>
I think all your concerns can be addressed by carefully using the metadata
solution?

ie, In file "lib.clj" (the generic api):

(ns lib)

(declare fns-to-be-implemented-in-platform-code)

(defn general-api-fn)

^{:platform :jvm} (load "jvm/lib")
^{:platform :python} (load "python/lib")

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