Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map Julia symbols to JavaScript strings #5

Open
sebastiang opened this issue Feb 26, 2015 · 2 comments
Open

Map Julia symbols to JavaScript strings #5

sebastiang opened this issue Feb 26, 2015 · 2 comments

Comments

@sebastiang
Copy link
Contributor

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.

@waTeim
Copy link
Owner

waTeim commented Feb 26, 2015

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.

@waTeim waTeim added this to the 1.1.0 milestone Mar 8, 2015
@waTeim waTeim removed this from the 1.1.0 milestone May 10, 2015
@sebastiang
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants