-
Notifications
You must be signed in to change notification settings - Fork 372
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
variadic if #962
variadic if #962
Conversation
Looking sweet. Can't wait for this to be available. Can you add docs for this? |
Just realized this kind of breaks |
Hm. Why is this failing? I ran nosetests before committing "variadic lif" without trouble. What was merged between my two commits? #920 "if-no-waste" (0585754) and #950 "f/one-arg-comparators" (b875fec). The complaint is
That is not supposed to be possible just from writing a macro. Something's wrong with the compiler. |
I think I found it. The "if-no-waste" is looking for |
Are the |
@tuturto docs added. |
looking good, 👍 from me. Could squash and rebase before merge, we have been a bit sloppy about that. |
@kirbyfan64 docs fixed. |
@hylang/core variadic if looks ready, but need second ack to merge. |
the evaluation of the condition is ``False``. | ||
``if / if* / if-not`` respect Python *truthiness*, that is, a *test* fails if it | ||
evaluates to a "zero" (including values of ``len`` zero, ``nil``, and | ||
``false``), and passes otherwise, but values with a ``__nonzero__`` method can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"values with a __bool__
method (or __nonzero__
on Python 2)"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch here. I think it would be preferable if Hy were consistent across host implementations, but that seems difficult to fix in this case. I'll mention __bool__
as the default and __nonzero__
as the special case for Python2.
_+1_ (I left some quibbling comments, but nothing that can't be addressed in a follow-up commit.) |
The `if` form now supports elif clauses. It works like `cond` but without the implicit `do`. The old `if` is now `if*` variadic lif now supports "ellif" clauses. Update if-no-waste compiler to use `if*` properly. (Sometimes one character is all it takes.) document if reword truthiness
The
if
form now supports elif clauses.It works like
cond
but without the implicitdo
.closes #830.
The old
if
is still available asif*
, but you don't need it since the 2- and 3- argument cases work exactly as before.