About foreach loops

Don nospam at nospam.com
Fri Jun 17 00:57:44 PDT 2011


bearophile wrote:
> Don:
> 
>> The alternative would be to create __iterator1234 as const, and then 
>> cast away const in the ++ step. Ugly, but would eliminate the 
>> performance cost for structs.
> 
> Isn't it undefined in D to modify a const?

Yes, but that's in the user world. This is in the compiler world.
Lowering frequently creates constructs which aren't well-formed D code.
For example, the compiler creates variables in comma expressions, which 
isn't legal D (it won't even compile).



More information about the Digitalmars-d mailing list