why does isForwardRange work like this?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 31 21:52:34 PDT 2014


On Thursday, 31 July 2014 at 22:21:10 UTC, Vlad Levenfeld wrote:
> Yes, I see the problem now. I can't think of any reason why I'd 
> want to make save anything but a function (especially since 
> `save` is a verb) but I guess someone out there might have a 
> good one.

It's Andrei's fault. I'm not quite sure what he was thinking. But 
unfortunately, we're stuck with it. So, it's just become one of 
D's little quirks that we have to learn and live with.

> So, what is gained by (inout int = 0) over ()? I wasn't even 
> aware that giving a default value for an unlabeled parameter 
> would compile. What does it do?

I've wondered that myself but never taken the time to look into 
it. However, according to this post:

http://forum.dlang.org/post/mailman.102.1396007039.25518.digitalmars-d-learn@puremagic.com

it looks like it convinces the compiler to make the function an 
inout function so that the range variable that's declared can be 
treated as inout and therefore be able to have ranges with inout 
in their type work.


More information about the Digitalmars-d-learn mailing list