Skip to content

Commit

Permalink
more loops to be more visible
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Feb 15, 2020
1 parent a04d55b commit c704754
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/loop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,30 @@ Loop
loopBody
Bitcoin script does not provide looping natively. Script achieves looping by repeating the loop body by the specified ``maxLoopCount`` times.
For example,
Bitcoin script does not provide looping constructs natively for security reasons.
sCrypt achieves looping by repeating the loop body ``maxLoopCount`` times.
For example, the loop

.. code-block:: solidity
loop (3) {
loop (10) {
x = x * 2;
}
is converted to
is equivalently unrolled to

.. code-block:: solidity
x = x * 2;
x = x * 2;
x = x * 2;
x = x * 2;
x = x * 2;
x = x * 2;
x = x * 2;
x = x * 2;
x = x * 2;
x = x * 2;
Because `loop unrolling <https://en.wikipedia.org/wiki/Loop_unrolling>`_ is done at compile time, the compiler must know ``maxLoopCount``, which has to be a constant number.
Expand Down

0 comments on commit c704754

Please sign in to comment.