Is old style compile-time foreach redundant?

Seb seb at wilzba.ch
Fri Jan 12 12:31:24 UTC 2018


On Sunday, 7 January 2018 at 02:17:02 UTC, Stefan Koch wrote:
> On Sunday, 7 January 2018 at 01:08:44 UTC, H. S. Teoh wrote:
>> On Sun, Jan 07, 2018 at 12:55:27AM +0000, Stefan Koch via 
>> Digitalmars-d-learn wrote:
>>> On Saturday, 6 January 2018 at 23:25:58 UTC, Ali Çehreli 
>>> wrote:
>>> > Is 'static foreach' sufficient for all needs or is there 
>>> > any value for regular foreach over compile-time sequences?
>> [...]
>>> No it's not.
>>> When you can use the old style do so. Since it puts less 
>>> stress on the
>>> compiler in the general case.
>>
>> Really? Based on a recent post by Jonathan Davis, the new 
>> static foreach actually runs faster in certain use cases.
>>
>>
>> T
>
> That might be true.
> If you are hitting some constant factor, however the big-o for 
> static foreach is worse then for tuple foreach.


FWIW there isn't any measurable performance penalty / difference.
We moved to use static foreach on Phobos recently: 
https://github.com/dlang/phobos/pull/5989


More information about the Digitalmars-d-learn mailing list