[Issue 4085] Steps toward a static foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 1 14:55:14 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4085



--- Comment #2 from bearophile_hugs at eml.cc 2011-06-01 14:50:48 PDT ---
Static foreach loops have a small disadvantage. This is the original code:

const int sum1 = foo!10() + foo!15() + foo!80();


The same using a static foreach:

int sum2;
foreach (x; TypeTuple!(10, 15, 80))
  sum2 += foo!x();


The small disadvantage is that now x can't be const.
In theory a smarter type system is able to see sum2 too is const.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list