I tried the CTFE example from Araq's Dr. Dobb's article from last November
proc mostSignificantBit(n : int) : int =
var m = n
while m != 0:
m = n shr 1
result += 1
result -= 1
const msb3999 = mostSignificantBit(3999)
when isMainModule:
echo(msb3999)
and nimrod (0.9.3) tells me
ctfe.nim(8) ctfe.nim(8) mostSignificantBit ctfe.nim(3, 2) Error: interpretation requires too many iterations
I didn't see any compiler options for dealing with this. Is this implemented?
I don't know if you can tweak it, but you don't want to wait until this function computes.
Because it never does.
I suppose you wanted:
proc mostSignificantBit(n : int) : int =
var m = n
while m != 0:
m = m shr 1
result += 1
result -= 1