On Friday, July 13, 2012 11:23:41 monarch_dodra wrote: > I think that in the case of your example, if "range" fulfills the > requirements for (at least) an input range, then "save" *should* > be called instead of "opSlice". I'm *think* this is what the > compiler does, but I'm not 100% sure.
The compiler never calls save. It will call opSlice on non-ranges, but it'll never call save on anything. It doesn't even know that save exists. It's unnecessary for ranges which aren't reference types, and you already have to worry about calling save on ranges that could be reference types any time that you pass them to a function that you don't want to consume it, so it's not really a big deal to have to call save with foreach for such ranges. Most range-based functions don't even use foreach much anyway. - Jonathan M Davis
