Compile time function execution...
BCS
ao at pathlink.com
Thu Feb 15 14:59:48 PST 2007
Reply to Walter,
> Michiel wrote:
>
>> Walter Bright wrote:
>>
>>> Many functions could be executed at compile time, but should not be.
>>>
>> When should they not be?
>>
> 1) Another poster mentioned a function that decompressed a built-in
> string - the whole point of having it compressed was to reduce the exe
> file size. Decompressing it at compile time defeats the purpose.
>
> 2) A function that simply takes too long at compile time. Compile time
> execution is going to be >100 times slower than run time.
>
> 3) As the spec mentions, there are cases where compile time would get
> different results than run time.
>
> 4) The compiler cannot determine in advance if a function can be
> executed at compile time. So speculatively doing so would have to be
> done for every function with constant arguments - this could be
> spectacularly slow.
>
> 5) It can cause problems for people who want to do runtime coverage
> testing - their code may actually never get executed, and they never
> notice.
>
6) when the whole program is const foldable, e.i. no runtime inputs, like
with some scientific software.
More information about the Digitalmars-d
mailing list