Transience of .front in input vs. forward ranges

deadalnix deadalnix at gmail.com
Wed Oct 31 16:05:18 PDT 2012


Le 31/10/2012 18:19, H. S. Teoh a écrit :
> On Wed, Oct 31, 2012 at 02:18:55PM +0100, deadalnix wrote:
>> Le 31/10/2012 01:56, H. S. Teoh a écrit :
>>>
>>> +1. I like this better than my proposal.
>>>
>>
>> The obvious drawback is that this make invalidating ranges harder to
>> write. But they seems to be more the exception than the rule.
>
> Actually, there is another problem: many algorithms' output will be
> transient or not depending on the input range. For example, we could
> write map to use the transient version of byLine, say, but then the
> range that map returns will also be transient (no longer safe).
>
> IOW, transience of .front is transitive in some cases. This again makes
> things complicated: as soon as you use a single transient range, it
> makes downstream ranges transient as well. So we're back to the problem
> of how to mark the range as transient in a transparent way. :-(
>

No it isn't always transitive. But that is true that it is in some cases.

This is why the code should default to the safe behavior. It is up to 
the programmer to ensure correctness when opting for an alternate behavior.


More information about the Digitalmars-d mailing list