See docs compiler message

Steven Schveighoffer schveiguy at yahoo.com
Tue Mar 6 20:02:50 UTC 2018


On 3/6/18 9:50 AM, ixid wrote:
> On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer wrote:
>> Now, there aren't actually docs for Transposed, but you can find it if 
>> you look at std.range.transposed:
>>
>> https://dlang.org/phobos/std_range.html#transposed
>>
> 
> Thanks, I had found that but that is not an explanation unless you have 
> a lot of prior technical understanding of what save is and why it's not 
> working. I guess it's a general doc quality issue - unless you're 
> already very knowledgeable it's pretty much useless to understand the 
> problem you have.

There are 2 problems. One is that Transposed offered .save as a member, 
when it shouldn't have (it's not a valid forward range). This is clear 
from trying to even use it as a forward range. Even when you call save, 
it destroys the original.

The other problem is that I think algorithms are seeing that .save is 
there, and thinking it's a forward range, so using it that way.

> I transposed a range of ranges to pass to a function to get the distance 
> between characters in strings. That works fine, as does printing the 
> result. But it then complains if I try to do anything like fold with the 
> result.

I have no idea how save is called, but apparently it is somewhere in there.

-Steve


More information about the Digitalmars-d-learn mailing list