jashkenas/coffee-script — Issue #1909: unroll simple comprehensions with known iteration count
Author: erisdiscord
Created: 2011-12-04 02:22:19+00:00
State: open

For instance, this:

[r, g, b] = Math.round(x * 255) for x in [@r, @g, @b]

some compile to something like this:

var r = Math.round(this.r * 255), g = Math.round(this.g * 255), b = Math.round(this.b * 255);

Notice that the number of iterations here is small and very clearly determined at compile time. Comments? Counterpoints?