jaked / ocamljs Goto Github PK
View Code? Open in Web Editor NEWJavascript back-end for OCamlc
Home Page: http://jaked.github.com/ocamljs
License: Other
Javascript back-end for OCamlc
Home Page: http://jaked.github.com/ocamljs
License: Other
The following code crashes the ocamljs compiler:
let f o = o#_get_x 1
it says:
Fatal error: exception Failure("bad method call")
while the following equivalent code compiles without crash:
let f o = let g = o#_get_x in g 1
It seems that the getter must not be applied directly to any argument, or ocamljs will die.
Although it is not fatal since there's workaround, it might be better if a more informative message is provided.
Similarly, the following code, which misses the setter's argument, will crash:
let f o = o#_set_x
The error message is the same:
Fatal error: exception Failure("bad method call")
Here is the modified oo_super test, it doesn't pass. http://gist.github.com/335377
Is it completely abandoned? Is there a relation to js_of_ocaml?
Just to inform the interested github reader. Thanks.
Pervasives.max_int and min_int have the following incorrect value, respectively: 1073741823 and 1073741824.
They are apparently not maximum or minimum integer in the JavaScript.
Though this might not be a bug in ocamljs.
The root cause is the definition in the stdlib/pervasives.ml in the OCaml distribution:
let min_int = 1 lsl (if 1 lsl 31 = 0 then 30 else 62)
let max_int = min_int - 1
which, if directly compiled into JS by ocamljs, will turn into a wrong value.
(For the meantime, I'm using this command to replace them with the correct value:
cat target-tmp.js |
gsed -E -e 's/var (min_int$$[0-9]+)./var \1 = -Math.pow(2,53);/g'
-e 's/var (max_int$$[0-9]+)./var \1 = Math.pow(2,53);/g' > target.js
(This is in my Makefile so the each occurrence of dollar ($) sign is doubled)
Similarly, min_float is 0. because it is defined as
let min_float =
float_of_bits 0x00_10_00_00_00_00_00_00L
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.