On Thursday, 28 February 2013 at 03:37:25 UTC, Walter Bright wrote:
On 2/27/2013 6:01 PM, Zach the Mystic wrote:
On Thursday, 28 February 2013 at 01:56:33 UTC, Walter Bright wrote:
On 2/27/2013 5:53 PM, Zach the Mystic wrote:
What if more than one
value can end the range, EOF, '\0'?

I have never seen a need for that.

Do you mean that you've never seen software that uses that, or that you've never
been convinced that such software couldn't be made simpler?

Pretty much both. For example, often a foreach loop will exit either when it runs out of data or some other condition is met. I don't see a need to work both of those conditions into the definition of a range.

My understanding of the logic of Sentinel Ranges so far is that switch statements and other control flow can proceed eagerly, because "go" values can be checked before the sentinel "stop" value, and "!empty" is known implicitly. I don't know exactly where the speed benefits of having a single "stop" value known at compile time come from.

Is this design focused more on your knowledge of how the compiler optimizes machine code, or on something which can be grasped at a higher level?

Reply via email to