You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can see that both ranges needs to be constructed, even though it is guaranteed only one of them will be used. And they don't even escape the scope. The problem is that one may need to build the range to use it and that may take a plenty of time.
The text was updated successfully, but these errors were encountered:
Unfortunately I don't think this kind of behavioral change to a public interface is allowed given Phobos' backward-compatibility policy. There may be existing code that relies on these side effects happening.
As a workaround, it should be possible to create a wrapper that forces a range to be evaluated lazily (by accepting it as a lazy argument). We could then write:
autolazyRange(R)(lazy R r)
{
// left as an exercise
}
voidmain()
{
choose(true, lazyRange(getRangeA), lazyRange(getRangeB));
}
...and this would have the desired behavior, without any risk of breaking compatibility.
Given that example code:
You can see that both ranges needs to be constructed, even though it is guaranteed only one of them will be used. And they don't even escape the scope. The problem is that one may need to build the range to use it and that may take a plenty of time.
The text was updated successfully, but these errors were encountered: