A SentinelInputRange is an InputRange with the following additions:
1. a compile time property 'sentinel' that is the terminating value of the range
2. empty is defined as: empty = (front == sentinel)
3. it is not necessary for empty to be called before front
A C style 0-terminated string is an example of a SentinelInputRange.
The additions to std.range would be:
1. isSentinelInputRange(T) which returns true if T is a SentinelInputRange
2. a unittest
3. documentation of this
An addition to std.string would be a function that takes a char* and returns a SentinelInputRange.
Motivation:
1. easy conversion of C strings to ranges
2. necessary for a fast implementation of a lexer
Any takers?

On 02/28/2013 02:11 AM, Walter Bright wrote:
> A SentinelInputRange is an InputRange with the following additions:
>> 1. a compile time property 'sentinel' that is the terminating value of
> the range
> 2. empty is defined as: empty = (front == sentinel)
> 3. it is not necessary for empty to be called before front
>> A C style 0-terminated string is an example of a SentinelInputRange.
>> The additions to std.range would be:
>> 1. isSentinelInputRange(T) which returns true if T is a SentinelInputRange
> 2. a unittest
> 3. documentation of this
>> An addition to std.string would be a function that takes a char* and
> returns a SentinelInputRange.
>> Motivation:
> 1. easy conversion of C strings to ranges
> 2. necessary for a fast implementation of a lexer
>> Any takers?
This is not general enough. The concept is not exclusive to input ranges.

On Thursday, 28 February 2013 at 01:14:31 UTC, Timon Gehr wrote:
> On 02/28/2013 02:11 AM, Walter Bright wrote:
>> A SentinelInputRange is an InputRange with the following additions:
>>>> 1. a compile time property 'sentinel' that is the terminating value of
>> the range
>> 2. empty is defined as: empty = (front == sentinel)
>> 3. it is not necessary for empty to be called before front
>>>> A C style 0-terminated string is an example of a SentinelInputRange.
>>>> The additions to std.range would be:
>>>> 1. isSentinelInputRange(T) which returns true if T is a SentinelInputRange
>> 2. a unittest
>> 3. documentation of this
>>>> An addition to std.string would be a function that takes a char* and
>> returns a SentinelInputRange.
>>>> Motivation:
>> 1. easy conversion of C strings to ranges
>> 2. necessary for a fast implementation of a lexer
>>>> Any takers?
>>> This is not general enough. The concept is not exclusive to input ranges.
I presume you're remembering that if something is a forward, bidirectional or random access range it is also an input range.
What further generality would you want?

On 02/28/2013 02:18 AM, John Colvin wrote:
> On Thursday, 28 February 2013 at 01:14:31 UTC, Timon Gehr wrote:
>> On 02/28/2013 02:11 AM, Walter Bright wrote:
>>> A SentinelInputRange is an InputRange with the following additions:
>>>>>> 1. a compile time property 'sentinel' that is the terminating value of
>>> the range
>>> 2. empty is defined as: empty = (front == sentinel)
>>> 3. it is not necessary for empty to be called before front
>>>>>> A C style 0-terminated string is an example of a SentinelInputRange.
>>>>>> The additions to std.range would be:
>>>>>> 1. isSentinelInputRange(T) which returns true if T is a
>>> SentinelInputRange
>>> 2. a unittest
>>> 3. documentation of this
>>>>>> An addition to std.string would be a function that takes a char* and
>>> returns a SentinelInputRange.
>>>>>> Motivation:
>>> 1. easy conversion of C strings to ranges
>>> 2. necessary for a fast implementation of a lexer
>>>>>> Any takers?
>>>>>> This is not general enough. The concept is not exclusive to input ranges.
>> I presume you're remembering that if something is a forward,
> bidirectional or random access range it is also an input range.
>> What further generality would you want?
Never mind. I was confused.

On Thursday, 28 February 2013 at 01:12:19 UTC, Walter Bright wrote:
> A SentinelInputRange is an InputRange with the following additions:
>> 1. a compile time property 'sentinel' that is the terminating value of the range
> 2. empty is defined as: empty = (front == sentinel)
> 3. it is not necessary for empty to be called before front
>> A C style 0-terminated string is an example of a SentinelInputRange.
>> The additions to std.range would be:
>> 1. isSentinelInputRange(T) which returns true if T is a SentinelInputRange
> 2. a unittest
> 3. documentation of this
>> An addition to std.string would be a function that takes a char* and returns a SentinelInputRange.
>> Motivation:
> 1. easy conversion of C strings to ranges
> 2. necessary for a fast implementation of a lexer
>> Any takers?
Seems smart. Patches up a hole in the armor of Ranges. What if more than one value can end the range, EOF, '\0'?

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?

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.
how about a predicate isSentinel instead of a fixed sentinel value?
That'd allow more flexibility such as more than one sentinel value.

On 2013-02-28 02:05:20 +0000, "timotheecour" <thelastmammoth@gmail.com> said:
> 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.
> > how about a predicate isSentinel instead of a fixed sentinel value?
> That'd allow more flexibility such as more than one sentinel value.
Not usable in a switch/case statement.
--
Michel Fortin
michel.fortin@michelf.ca
http://michelf.ca/

>> how about a predicate isSentinel instead of a fixed sentinel value?
>> That'd allow more flexibility such as more than one sentinel value.
>> Not usable in a switch/case statement.
why is that needed?