-
Website
http://skydeck.com/blog -
Original page
http://skydeck.com/blog/programming/ocamljs-ocaml-to-javascript-compiler -
Subscribe
All Comments -
Community
-
Top Commenters
-
Kenny Lee
1 comment · 1 points
-
Gustaf Alstromer
1 comment · 1 points
-
Jason Devitt
28 comments · 1 points
-
DupliMark
1 comment · 1 points
-
Metro PCS
2 comments · 1 points
-
-
Popular Threads
-
T-Mobile Opens Up The US Cell Phone Market
4 weeks ago · 4 comments
-
BlackBerry OS 5.0 and the Storm
3 weeks ago · 2 comments
-
T-Mobile Opens Up The US Cell Phone Market
Did you have access to some documentation on the internals of the ocaml compiler or did you just read the source code?
In case you had access to docs, could you please tell me what you had to do to obtain it?
If you just read the source would you like to write some documents (a tutorial or a blog post or whatever you like) explaining a bit the internals of the compiler?
I'm working on a snippet manager to ease the distribution and reuse of ocaml code and to reduce the size of the binary by linking only those pieces of libraries that are used in your application and not the whole module. We already have a working prototype implementation using ocamldoc but we need to access the internals of the compiler to get a better tool. Our snippet manager will be released as free software.
If you are interested I can provide you further details.
http://cadmium.x9c.fr/downloads.html
Your snippet manager would be useful in ocamljs since minimizing the resulting Javascript is important for web apps.
let foo() =
let a = ref [] in
for i = 1 to 5 do
a := (fun x -> x + i) :: !a;
done;
Array.of_list !a;;
let foo_test() =
let a = foo() in
assert ((a.(0) 3) == 4);
assert ((a.(1) 3) == 5);;
foo_test();;
for (var i$60 = 1; i$60
The code should compile to someting like
for (var i$60 = 1; i$60 <= 5; i$60++) (function() { var i$60$ = i$60; a$59 = $(_f(function (x$61) { return x$61 + i$60$; }), a$59)})();
instead of
for (var i$60 = 1; i$60 <= 5; i$60++) a$59 = $(_f(function (x$61) { return x$61 + i$60; }), a$59);
Only functions, not blocks, are scopes in javascript.
The assers in Isaacs code should obviously be
assert ((a.(0) 3) == 8);
assert ((a.(1) 3) == 7);;
And print_int in ocamljs adds a newline that ocaml proper doesn't add.