I have a library written in Nim and I want to use it in ClojureScript since the 
lib written in ClojureScript is kind of slow. So I run
    
    
    nim js -o:js-lib/index.js ./src/cirruParser.nim
    
    
    Run

and got a JavaScript file. Then I added exports.parseCirru = parseCirru at the 
end of the file for exporting the function parseCirru. It turned out to be 
faster than my ClojureScript version(despite that I need the data structure in 
ClojureScript).

I looked in to the generated code and saw something like:
    
    
            framePtr = F;
                    F.line = 34;
                    var e_14207 = null;
                    F.line = 37;
                    e_14207 = {m_type: NTI3850, parent: null, name: null, 
message: null, trace: null, raiseId: 0, up: null};
                    F.line = 38;
                    e_14207.message = nimCopy(null, message_14066, NTI138);
                    F.line = 39;
                    raiseException(e_14207, "AssertionError");
            framePtr = F.prev;
    
    
    Run

I got a question, is there something like "optimization level" in compiling to 
JavaScript? I'm not sure what these code means, it's like writing to F.line 
just with different numbers.

Also strange to me that I don't get exports.foo = funcFoo by default as I added 
{.exports.} since it's how most of us using JavaScript modules today.

Anything I need to know beyond tips listed on [Nim Backend 
Integration]([https://nim-lang.org/docs/backends.html#backends-the-javascript-target)](https://nim-lang.org/docs/backends.html#backends-the-javascript-target\))?

Reply via email to