Yet another nail in the autodecoding coffin

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 29 12:07:32 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15972

We are going to keep getting these obscure corner case bugs as long as
we still have autodecoding, i.e., an incongruity in how we handle narrow
strings vs. ranges of other element types (including ranges of char /
wchar).

I considered other alternatives, but none seem workable to me:

1) I don't think it's reasonable to demand that users write
"#".repeat(i) instead of '#'.repeat(i) in this case, for example.
(Besides, it then returns a range of ranges of ranges, and would require
an additional invocation of .joiner, which is again not something new
users would think of doing.)

2) Making '#'.repeat(i) return a range of dchar instead will break in
other ways, because byCodeUnit currently relies on autodecoding *not*
recognizing ranges of bare chars, and if we start automatically turning
ranges of char into ranges of dchar, we're going to open up a whole new
can o' worms.  Plus, users will be surprised at why they get a range of
dchar out of '#'.repeat(i) instead of a range of char.

I say, kill autodecoding with fire.  Evidence is growing that this was a
bad design decision.


T

-- 
Truth, Sir, is a cow which will give [skeptics] no more milk, and so they are gone to milk the bull. -- Sam. Johnson


More information about the Digitalmars-d mailing list