On Monday, 24 March 2014 at 16:31:42 UTC, Andrei Alexandrescu wrote:
On 3/24/14, 2:02 AM, monarch_dodra wrote:
On Sunday, 23 March 2014 at 21:23:18 UTC, Andrei Alexandrescu wrote:
Here's a baseline: http://goo.gl/91vIGc. Destroy!

Andrei

Before we roll this out, could we discuss a strategy/guideline in
regards to detecting and handling invalid UTF sequences?

I think std.array.front should return the invalid dchar on error, and popFront should attempt to resync on error.

Andrei

That sounds good to me (I think). Better than a straight up assert anyways...

...which is what the code you submitted does.

Also, I think relying on bounds checking is wrong: Disabling bounds checking mean you are OK for memory corruption for *wrong code*. I don't think invalid string is wrong code. 'front' should do an actual "if", and "assert(0)" when needed. This should have no impact on performance BTW, if done with pointer extraction ("slice.ptr[1]"), and in a trusted context.

Of course, this is all assuming we are asserting at all.

Reply via email to