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

Logical (and) & (or) should accept any number of arguments #835

Closed
gilch opened this issue Jul 2, 2015 · 2 comments
Closed

Logical (and) & (or) should accept any number of arguments #835

gilch opened this issue Jul 2, 2015 · 2 comments

Comments

@gilch
Copy link
Member

gilch commented Jul 2, 2015

;;; Clojure
user=> (and)
true
user=> (and 'foo)
foo
user=> (or)
nil
user=> (or 'foo)
foo
;;; Common Lisp
* (and)

T
* (and 'foo)

FOO
* (or)

NIL
* (or 'foo)

FOO
;;; Hy
=> (and)
  File "<input>", line 1, column 1

  (and)
  ^---^
HyTypeError: `and' needs at least 2 arguments, got 0.

=> (and 'foo)
  File "<input>", line 1, column 1

  (and 'foo)
  ^--------^
HyTypeError: `and' needs at least 2 arguments, got 1.

=> (or)
  File "<input>", line 1, column 1

  (or)
  ^--^
HyTypeError: `or' needs at least 2 arguments, got 0.

=> (or 'foo)
  File "<input>", line 1, column 1

  (or 'foo)
  ^-------^
HyTypeError: `or' needs at least 2 arguments, got 1.

Again I am surprised. There's no good reason for a minimum of 2 arguments here. Hy already supports 0-, and 1-arg +, even though Python doesn't*.

;;; hy --spy
=> (+)
(0 + 0)
0
=> (+ 42)
(0 + 42)
42

Why should Hy do this even though Python can't?
The same reasoning should apply to and and or.

*Python actually does have a unary +.

@Kodiologist
Copy link
Member

Kodiologist commented Sep 25, 2016

This can be closed. Nullary and and or now work, and are tested in native_tests/language.hy.

@gilch
Copy link
Member Author

gilch commented Sep 25, 2016

And the Unary case too.

@gilch gilch closed this as completed Sep 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants