Open sebastiang opened 9 years ago
Hmm yea, I'm not sure about the way to best solve this. I'm leaning towards making a JavaScript type with convenient methods. Ultimately I think it would good to have a solution that leverages the applicable features of EMCAScript 6. To get an idea, these are partially implemented by io.js. And in the the main EMCA doc, enum will eventually be reserved. At least something should/can be implemented quickly, but It would be nice to have a thought out path. Maybe an intermediate solution? I'm wary about the speed implications and 2nd guessing the Julia programmer/multiple dispatch of using jl_symbol(string) if string fails, especially if there are multiple (n) substitutions possible; there would potentially be 2^n attempts some of which might have different meaning.
I think you're right that an explicit JavaScript type that matches a Julia symbol is the clearest thing. ES6 describes such a thing, and it's supported in at least the version of node
I'm using (v0.12.7
). See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
It is common practice to return enumeration-style results from Julia as symbols (
:symbol
). The parallel idiom in JavaScript is strings.The other way around is harder: passing a JavaScript string to a Julia function should result in a Julia string, but if possible, it might be nice to also try finding a dispatch where the string is converted to a symbol if the string dispatch does not resolve.