On 2/27/2013 9:28 PM, Jonathan M Davis wrote:
But you have to deal with D strings, not C strings if you're dealing with ranges. char* isn't a range. So, unless you're talking about wrapping a char* in a range, char* isn't going to work. And simply appending 0 to the end of a D string isn't enough, because isSentinelnputRange would fail, because std.array.empty doesn't match it. So, you need a wrapper even if it's only to pass the template constraint. That being the case, regardless of whether you're dealing with char* or string, you need a wrapper.
Again, please see how lexer.c works. I assure you, there is no double copying going on, nor is there a double test for the terminating 0.
And what ranges other than strings can take advantage of anything like this?
I've mentioned a couple already in this thread, and I'll add another - an interpreter bytecode, you can see an example in the (former) std.regexp. Search for "REend".
What are we gaining here
High speed processing.
So, why not just special case strings or arrays in the few situations where something like this is needed, especially when it would be so easy to do?
Sentinels structure the code differently.
