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

Make and and or work with 0 arguments. #4696

Closed
mlucy opened this issue Aug 15, 2015 · 9 comments
Closed

Make and and or work with 0 arguments. #4696

mlucy opened this issue Aug 15, 2015 · 9 comments

Comments

@mlucy
Copy link
Member

mlucy commented Aug 15, 2015

Now that we have r.args it's extremely annoying that they don't with with no arguments. (Also, other languages like Common Lisp with arbitrary-arity and and or operators have 0-argument version.)

There's another issue for this somewhere but I couldn't find it searching.

@mlucy mlucy modified the milestones: 2.2-polish, 2.2 Aug 15, 2015
@mlucy
Copy link
Member Author

mlucy commented Aug 15, 2015

Bumping this to 2.2 not because it's particularly important but because I have a fix for #4132 that also changes this, so it would be nice to squeeze it into the discussion period.

@danielmewes
Copy link
Member

What are the results of these terms when called with zero arguments?

@mlucy
Copy link
Member Author

mlucy commented Aug 18, 2015

In SBCL (and this makes sense to me intuitively):

* (and)
T
* (or)
NIL

The reason this makes sense intuitively to me is that variadic and works if you define (and a b) <=> (and a b true) and or works if you define (or a b) <=> (or a b false).

@deontologician
Copy link
Contributor

Just one minor data point, we default to true with 0-arg .contains, which could be seen as an or-ish operation

@deontologician
Copy link
Contributor

also, I personally think 0-arg or returning null is yucky, but I don't have a strong opinion

@mlucy
Copy link
Member Author

mlucy commented Aug 27, 2015

@deontologician --I think in ReQL 0-arg or should return false. It returns NIL in CL because that's the only false value.

@danielmewes
Copy link
Member

I think contains is actually more similar to and, assuming the documentation is correct: "When called with values, returns true if a sequence contains all the specified values."

Allowing 0-argument or with r.or() -> false and 0-argument and with r.and() -> true sounds good to me.

@danielmewes
Copy link
Member

Marking as settled with
r.or() -> false and r.and() -> true

@danielmewes danielmewes modified the milestones: 2.2, 2.3 Oct 5, 2015
eliangidoni added a commit to eliangidoni/rethinkdb that referenced this issue Oct 24, 2015
eliangidoni added a commit to eliangidoni/rethinkdb that referenced this issue Oct 30, 2015
@mlucy
Copy link
Member Author

mlucy commented Nov 10, 2015

This is in next (the review was completed a while ago and I had just forgotten to merge it in).

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

3 participants