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

Closures #22

Closed
mrft opened this issue Mar 4, 2014 · 5 comments
Closed

Closures #22

mrft opened this issue Mar 4, 2014 · 5 comments

Comments

@mrft
Copy link

mrft commented Mar 4, 2014

this is more of a question than an issue, but:

You say closures don't map to javascript, but couldn't this example

g.v(1).out().gather("{it.size()}");

also be written as

g.v(1).out().gather( function(it) { return it.size(); } );

in javascript?

@jbmusso
Copy link
Owner

jbmusso commented Mar 4, 2014

I think I'm in favor of this syntax, and it will most likely be supported somewhere on the path toward v1.0. I've thought of adding this in the past though that'd require quite a bit of refactoring (ie. rewrite the way arguments are handled).

Currently, any strings matching the /^{.*}$/ Regex pattern are considered closures. This will certainly cause bugs when passing "literal" string arguments matching this pattern. This is definitely an issue that needs to be addressed.

@jbmusso
Copy link
Owner

jbmusso commented Mar 4, 2014

To answer your question: I see no reason why this couldn't be written in JavaScript the way you wrote it :).

@jbmusso
Copy link
Owner

jbmusso commented Mar 14, 2014

By the way, thanks for showing interest in gRex. Feel free to browse and experiment with the current develop branch, I'd happily and carefully review your suggestions and try to improve the library.

@jbmusso jbmusso closed this as completed Mar 14, 2014
@jbmusso
Copy link
Owner

jbmusso commented Mar 25, 2014

Note that as was discussed recently on irc, the following could also work with appropriate function binding:

g.v(1).out().gather(function() { return this.size(); } );

@jbmusso
Copy link
Owner

jbmusso commented Apr 23, 2014

I've been looking today for ways to implement it and I believe ES6 Proxy are needed.

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