Article: Why Const Sucks

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Mar 6 19:14:39 UTC 2018


On Tuesday, March 06, 2018 19:06:25 Martin Nowak via Digitalmars-d-announce 
wrote:
> On Tuesday, 6 March 2018 at 18:17:58 UTC, Jonathan M Davis wrote:
> > I'm not actually convinced that killing auto-decoding is really
> > much better.
>
> I don't think the problem is auto-decoding in string range
> adapters, but repeated validation.
> https://issues.dlang.org/show_bug.cgi?id=14519#c32
> If you know that sth. works on code units just use
> .representation.
>
> There is the related annoyance when the user of a function
> presumably knows to only deal with ASCII strings but algorithms
> fail, e.g. splitter.popBack or binary search. This one is tricky
> because broken unicode support is often rooted in ignoring it's
> existence.

Yes, using stuff like representation or byCodeUnit helps to work around the
auto-decoding, but as long as it's there, you have to constantly work around
it if you care about efficiency with strings and/or want to be able to
retain the original string type where possible. At this point, I think that
it's pretty clear that we wouldn't have it if we could do stuff from
scratch, but of course, we can't do stuff from scratch, because that would
break everything.

- Jonathan M Davis



More information about the Digitalmars-d-announce mailing list