DIP 1022--foreach auto ref--Community Review Round 1

rikki cattermole rikki at cattermole.co.nz
Thu Aug 8 13:06:28 UTC 2019


On 09/08/2019 12:52 AM, Dukc wrote:
> On Thursday, 8 August 2019 at 12:38:51 UTC, rikki cattermole wrote:
>> - In the first alternative a disadvantage is listed but no advantages. 
>> An advantage of it is that there would be no breaking changes unlike 
>> the proposed solution which has an unknown amount of breakage.
> 
> Read the paragraph slower :D.

Darn it, you're right!

>>
>> If we could get an idea of the severity (1-2 modules vs half vs almost 
>> all of Phobos) of the breakage being proposed, that would great.
> 
> Remember that nothing will break before deprecation period ends. If it 
> proves to be too bad we can back up and go with alternative #1 instead.

If we can do a little bit of research now to prevent changing an 
implementation after a DIP is accepted, we probably should.

When no code is written, changing tactic is cheap :)

>>
>> - What is the interaction with indexes? No mention of them, nor example.
> 
> Yes, this is likely worth an explicit mention. Same as with the 
> equivalent regular or ref foreach, depending on which is chosen 
> according to the rules menitoned on the DIP.
> 
>>
>> - The examples you have may look good for an implementer, but for 
>> everybody else perhaps some examples using concrete types that ignore 
>> the foreach body would be a good edition. Just to make it clear what 
>> we're getting out of it. I.e.
>>
>> RangeWithoutRefFront expr; // T front()
>>
>> foreach(v; expr) // ok
>> foreach(ref v; expr) // Success but will be error after deprecation
>> foreach(auto ref v; expr) // ok
> 
> Isn't the EMSI-containers example already like yours? Or did you mean 
> that your example as how-not-to example?

The EMSI-containers example while useful, has a lot of extra code that 
you have to think about. Or at least it does for me.

Basically what I would like to have is an expression +
foreach statements that are current (and will remain) +
foreach statements that will no longer be valid +
foreach statements that will become valid

Essentially the bare bones of what is changing and something to compare 
against. So if the only thing you look at within the DIP, this will tell 
you pretty much what you need to know.


More information about the Digitalmars-d mailing list