Wanted: best way to express default expectations

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Mon Oct 14 15:26:03 UTC 2019


On Monday, 14 October 2019 at 13:00:14 UTC, Dukc wrote:
> On Saturday, 12 October 2019 at 16:48:56 UTC, Jesse Phillips 
> wrote:
>>
>> Sorry forgot the foreach break part.
>>
>> import std.stdio;
>> void main()
>> {
>> import std.algorithm;
>> import std.range;
>>
>> foreach(i; iota(10)
>>     .filter!(x => x%2)
>>     .until!(x => x>5)
>>     .map!"a * a"
>>     .filter!(x => x%4)) {
>>     i.writeln;
>>     break;
>>    }
>> }
>>
>> Note this is all done lazily so there is no walking of the 
>> iota which happens.
>
> This is not exactly what I wanted, but probably the best 
> alternative overall. At least it's better than in C#, as you 
> don't sacrifice as much performance for using functional 
> pipelines.

How is not what you want? I realize it doesn't use the same 
foreach break structure, but then there is no alternative.

>
> But I still think an `if_not`, `ifnot` or some similar keyword 
> would have it's place. Does anybody agree? Read: might it be 
> worth a DIP?

I don't think it is worth it and I do think the range based 
approach is direction people should head.




More information about the Digitalmars-d mailing list