Proposal for SentinelInputRange

Walter Bright newshound2 at digitalmars.com
Thu Feb 28 13:42:34 PST 2013


On 2/28/2013 10:52 AM, Jonathan M Davis wrote:
> Notice that it has to check for empty every time that the front is popped, and
> it can't avoid that,


Yes it can avoid it - that is the whole point. Notice there are no checks for 
the sentinel here - but the code is correct:

             case '>':
                 p++;
                 if (*p == '=')
                 {   p++;
                     t->value = TOKge;                   // >=
                 }
                 else if (*p == '>')
                 {   p++;
                     if (*p == '=')
                     {   p++;
                         t->value = TOKshrass;           // >>=
                     }
                     else if (*p == '>')
                     {   p++;
                         if (*p == '=')
                         {   p++;
                             t->value = TOKushrass;      // >>>=
                         }
                         else
                             t->value = TOKushr;         // >>>
                     }
                     else
                         t->value = TOKshr;              // >>
                 }
                 else
                     t->value = TOKgt;                   // >
                 return;



More information about the Digitalmars-d mailing list