Fix Phobos dependencies on autodecoding
Walter Bright
newshound2 at digitalmars.com
Thu Aug 15 19:36:07 UTC 2019
I ran into that as well with the 3 PRs I did:
fix array(String) to work with no autodecode
https://github.com/dlang/phobos/pull/7133
fix assocArray() unittests for no autodecode
https://github.com/dlang/phobos/pull/7134
fix unittests for array.join() for no autodecode
https://github.com/dlang/phobos/pull/7135
More specifically, the ElementType template returns a dchar for an autodecodable
string, and char/wchar for a non-autodecodable string. I suspect that most
people are not aware of this, and code that uses ElementType may already be
subtly broken.
Note that the documentation for ElementType is also wrong,
https://github.com/dlang/phobos/pull/
because isNarrowString is NOT THE SAME THING as an autodecoding string! The
difference is isNarrowString excludes stringish aggregates and enums with a
string base type, while autodecoding types include them.
Does this confuse anyone? It confuses me. I can never remember which is which.
Autodecoding is not only a conceptual mistake, the way it is implemented is a
buggy, confusing disaster. (isNarrowString is often incorrectly used instead
isAutodecodableString in Phobos.)
I think the only solution is to "rip the band-aid off" and have ElementType give
the code unit type when autodecoding is disabled.
More information about the Digitalmars-d
mailing list