Closed mrft closed 10 years ago
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.
To answer your question: I see no reason why this couldn't be written in JavaScript the way you wrote it :).
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.
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(); } );
I've been looking today for ways to implement it and I believe ES6 Proxy are needed.
this is more of a question than an issue, but:
You say closures don't map to javascript, but couldn't this example
also be written as
in javascript?