Skip to content

ReQL proposal: Passing ReQL api functions as well as lambdas #1320

Closed

Description

@wmrowan

Currently we officially support and recommend the following syntax:

r.expr([1,2]).reduce(lambda x,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.

Activity

  1. ghost assigned on Aug 19, 2013
  2. wmrowan commented on Aug 19, 2013

    @wmrowan
    ContributorAuthor

    Note: this has nothing to do with currying. The following doesn't currently work nor will it.

    r.expr([1,2]).map(r.add(1))
  3. jdoliner commented on Aug 19, 2013

    @jdoliner
    Contributor

    What would the result of:

    r.expr([1,2]).map(r.add(1))

    be under this proposal?

  4. wmrowan commented on Aug 19, 2013

    @wmrowan
    ContributorAuthor

    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".

  5. jdoliner commented on Aug 19, 2013

    @jdoliner
    Contributor

    Whoops, better question. What would the result of r.add(1) be under this proposal?

  6. wmrowan commented on Aug 19, 2013

    @wmrowan
    ContributorAuthor

    This proposal has nothing to do with the behavior of r.add(1). Currently it results in an argument error. That wouldn't change.

  7. jdoliner commented on Aug 19, 2013

    @jdoliner
    Contributor

    Currently it results in an argument error.

    In 2 out of 3 official drivers it does not result in an error.

  8. wmrowan commented on Aug 19, 2013

    @wmrowan
    ContributorAuthor

    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.

  9. coffeemug commented on Aug 20, 2013

    @coffeemug
    Contributor

    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).

  10. wmrowan commented on Aug 20, 2013

    @wmrowan
    ContributorAuthor

    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.

  11. thelinuxlich commented on Mar 26, 2018

    @thelinuxlich

    @srh I think #1312 already covers this

  12. modified the milestones: backlog, duplicate on Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions