> As awesome as this sounds, wouldn't it first require a
> native implementation to be created for each language prior to Clojure
> in Clojure running on the platform?

No, you don't need to write a native port for each platform.

Typically, you break the compiler into two broad parts: the platform
independent compiler and the code generator for each platform. (Each
of these has several parts internally.)

The idea is that most of the compiler is in the platform independent
part. This creates some sort of intermediate (but fairly low-level)
representation of your program. Then you have a smaller part for each
system that generates the exact instruction set for that system. So
you have one big compiler/library bundle and n code generators, one
for each platform. All of this is written in the source language (in
this case Clojure).

Now, the important thing is that the code generator for a target
machine X doesn't have to run *on* machine X. It can run on any
machine that supports the source language.

So say we have Clojure-in-Clojure on the JVM and we decide that we
want to run Clojure in Flash by compiling to ActionScript. What we
need to do is create an ActionScript code generator for the Clojure
compiler. Then, on the JVM, we compile all of Clojure using the
ActionScript code generator instead of the JVM code generator. The
resulting output *is* native Clojure for Flash. Typically (though not
always), you'll go ahead and recompile your compiler from Flash
generating a "pure" Flash compiler.

Thus, we never go through a "bootstrap" process on each new target
platform, we start by building a cross-compiler (which is identical to
the native compiler, but running on a platform other than the target)
and use that to get our bootstrap.

In reality, porting Clojure-in-Clojure will be more difficult than
this because of things like differences in GC between platforms. Also,
I suspect the first versions of Clojure-in-Clojure won't be quite so
nicely divided as that. But this is the basic theory.

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