You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ReQL proposal: Passing ReQL api functions as well as lambdas #1320
Currently we officially support and recommend the following syntax:
r.expr([1,2]).reduce(lambdax,y: x+y)
It just so happens though that our current implementation (at least in the Python driver) is agnostic to the type and origin of the passed function. The following also works (though currently blocked by an unrelated bug in next):
r.expr([1,2]).reduce(r.add)
This proposal is to standardize this form, make sure it is available in all drivers, and document it as a real feature.
The same as it is now. Either an argument error from the either the driver or the server "expected 2 or more arguments to r.add" or a type error from the server "expected 2 argument function but found number".
I consider the current python behavior to be a bug. I don't know how the ruby driver does argument checking but it could have a similar problem.
In any case, this question is completely outside of the scope of this issue. If you want to argue about driver behavior with respect to single argument r.add etc. please comment on #1312. I believe (at least in the case of r.add) that the server accepts a single argument version in which case it becomes a no-op. While that is behavior we'll have to address if / when we decided to look at function currying, it is not relevant here since thing.map(r.add(1)) still would fail with a type error on the server, as I said above.
I'd like to move this to backlog as this is a fairly low priority issue. Given that our main concern for 1.9 and 2.0 is performance and scalability, I don't think we should worry about this type of issues for now (this seems reasonably esoteric and I wouldn't worry about until 2.0 is out).
The syntax described in this issue already works by accident in the Python driver. I looked into getting the same working in the JS driver but a similar issue (related to how variatic functions report the number of parameters they take) is blocking us there. A solution to that problem will not be a straight forward as the equivalent in the Python driver. @AtnNn's idea of enforcing lambda airity on the client side could potentially make this a lot easier in all drivers but would involve superficially more extensive changes. Insert here the usual caveat about ruby.
If / when we decided to pick this up again this should be relatively straight forward to finish. I'd say this issue is more about documenting this particular syntax option than actually getting any new code to work. If I get bored working on my much more important work for 1.9 I might just finish fixing this for JS. We can just leave the feature undocumented until we're ready to slip some line about it in an otherwise slow release announcement.
Activity
wmrowan commentedon Aug 19, 2013
Note: this has nothing to do with currying. The following doesn't currently work nor will it.
jdoliner commentedon Aug 19, 2013
What would the result of:
be under this proposal?
wmrowan commentedon Aug 19, 2013
The same as it is now. Either an argument error from the either the driver or the server "expected 2 or more arguments to r.add" or a type error from the server "expected 2 argument function but found number".
jdoliner commentedon Aug 19, 2013
Whoops, better question. What would the result of
r.add(1)be under this proposal?wmrowan commentedon Aug 19, 2013
This proposal has nothing to do with the behavior of
r.add(1). Currently it results in an argument error. That wouldn't change.jdoliner commentedon Aug 19, 2013
In 2 out of 3 official drivers it does not result in an error.
wmrowan commentedon Aug 19, 2013
I consider the current python behavior to be a bug. I don't know how the ruby driver does argument checking but it could have a similar problem.
In any case, this question is completely outside of the scope of this issue. If you want to argue about driver behavior with respect to single argument
r.addetc. please comment on #1312. I believe (at least in the case ofr.add) that the server accepts a single argument version in which case it becomes a no-op. While that is behavior we'll have to address if / when we decided to look at function currying, it is not relevant here sincething.map(r.add(1))still would fail with a type error on the server, as I said above.coffeemug commentedon Aug 20, 2013
I'd like to move this to backlog as this is a fairly low priority issue. Given that our main concern for 1.9 and 2.0 is performance and scalability, I don't think we should worry about this type of issues for now (this seems reasonably esoteric and I wouldn't worry about until 2.0 is out).
wmrowan commentedon Aug 20, 2013
The syntax described in this issue already works by accident in the Python driver. I looked into getting the same working in the JS driver but a similar issue (related to how variatic functions report the number of parameters they take) is blocking us there. A solution to that problem will not be a straight forward as the equivalent in the Python driver. @AtnNn's idea of enforcing lambda airity on the client side could potentially make this a lot easier in all drivers but would involve superficially more extensive changes. Insert here the usual caveat about ruby.
If / when we decided to pick this up again this should be relatively straight forward to finish. I'd say this issue is more about documenting this particular syntax option than actually getting any new code to work. If I get bored working on my much more important work for 1.9 I might just finish fixing this for JS. We can just leave the feature undocumented until we're ready to slip some line about it in an otherwise slow release announcement.
thelinuxlich commentedon Mar 26, 2018
@srh I think #1312 already covers this