No description
Find a file
Felipe S. S. Schneider b4297abbbb Retire project
2021-07-27 10:37:15 -03:00
docs Add a simple runnable example to the docs 2021-07-06 14:42:04 -03:00
src Remove unused submodule 2021-07-06 14:56:25 -03:00
tests Apply nimpretty 2021-07-06 14:35:56 -03:00
.gitignore Start Nimble project 2021-07-05 22:22:20 -03:00
LICENSE Initial commit 2021-07-05 22:20:45 -03:00
README.md Retire project 2021-07-27 10:37:15 -03:00
unrolled.nimble Change required Nim version and add install instructions 2021-07-17 13:18:34 -03:00

WARNING: this project has been retired. For a Rust-based alternative, see crunchy.

unrolled

Unroll for-loops at compile-time.

var total: int
unroll for i in 1..3:
  total += i

The above generates the following code (check with expandMacros)

var total: int
block:
  total += 1
block:
  total += 2
block:
  total += 3

(The usage of blocks ensure variables never "leak".)

Note: currently, we have two serious known bugs, one regarding variable definitions in the loop body (see #1), and one about nested loops (see #2). I expect to solve them some time soon.

Installation

unrolled supports Nim 1.0.0+ and can be installed using Nimble:

$ nimble install unrolled

Other projects