Why is ElementType!(char[]) == dchar?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 9 07:33:23 PDT 2016


On Sat, Jul 09, 2016 at 11:57:36PM +1200, rikki cattermole via Digitalmars-d-learn wrote:
> On 09/07/2016 11:46 PM, Tofu Ninja wrote:
> > On Saturday, 9 July 2016 at 11:35:24 UTC, Tofu Ninja wrote:
> > > On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote:
> > > > On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote:
> > > > > Seems pretty silly to me...
> > > > 
> > > > due to universally beloved autodecoding.
> > > 
> > > Hmmm... I dont really know the history of autodecoding, why was that
> > > supposed to be a good idea?
> > 
> > Hmm, well I fixed my problem that originally prompted me to ask this by
> > using ubyte instead of char. Still kinda curious on the whole
> > autodecoding thing and why it's even a thing.
> 
> In this case, its not aut odecoding.
[...]

Actually, this is exactly what autodecoding is about. The .front of
string and wstring are always decoded to dchar.  A long time ago when
this was first written it was deemed a good idea, but over the years
experience has shown that it was a bad design (though some may argue
this point). Nowadays we're trying to steer away from it, but due to the
large amount of Phobos code that depends on it, it's probably here to
stay for the next little while yet.  (My hope is that eventually it will
become irrelevant and deprecable... but we're far from that right now.)


T

-- 
What doesn't kill me makes me stranger.


More information about the Digitalmars-d-learn mailing list