|
|
|
|
|
by tom_mellior
3015 days ago
|
|
> I don't think that programmers want big loops to unroll. Right, well, it depends. That's why I think unconst should be the default and unrolling should be requested explicitly by using something like let fib_2000 = specialize (fib 2000)
where specialize is a language built-in that triggers the unrolling. And then, if the user really does want you to specialize fib 2147483647, it would honor that too, without your arbitrary unrolling cutoff. And if it takes too long, well, the user wanted it that way. That is user control. Arbitrary hidden cutoffs are not. |
|
Another reason loops are unrolling by default is that there are many situations where constexprs have to completely fold at compile time, and you need a guarantee that they do. A common example is handling keyed varargs. You need to be able to iterate through the keys and build local variables from that without any code being generated.
If a compile time unroll takes forever, there's practically no clean way to debug that.