Skip to content

Commit

Permalink
and/or now short-circuit
Browse files Browse the repository at this point in the history
 Updated to reflect that and/or actually short-circuit now.
  • Loading branch information
bcj committed Mar 14, 2014
1 parent a11f92d commit a210a67
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions docs/language/api.rst
Expand Up @@ -151,20 +151,14 @@ case the first false value will be returned. Examples of usage:
=> (and True [] False True)
[]
.. note:: `and` shortcuts and stops evaluating parameters as soon as the first
false is encountered. However, in the current implementation of Hy
statements are executed as soon as they are converted to expressions.
The following two examples demonstrates the difference.
.. note::

`and` shortcuts and stops evaluating parameters as soon as the first
false is encountered.

.. code-block:: clj
=> (and False (print "hello"))
hello
False
=> (defn side-effects [x] (print "I can has" x) x)
=> (and (side-effects false) (side-effects 42))
I can has False
False
Expand Down Expand Up @@ -919,21 +913,13 @@ parameter will be returned.
1
.. note:: `or` shortcuts and stops evaluating parameters as soon as the first
true is encountered. However, in the current implementation of Hy
statements are executed as soon as they are converted to expressions.
The following two examples demonstrates the difference.
true is encountered.

.. code-block:: clj
=> (or True (print "hello"))
hello
True
=> (defn side-effects [x] (print "I can has" x) x)
=> (or (side-effects 42) (side-effects False))
I can has 42
42
print
-----
Expand Down

0 comments on commit a210a67

Please sign in to comment.