[phobos] isStringLike
Walter Bright via phobos
phobos at puremagic.com
Mon Oct 26 14:27:37 PDT 2015
On 10/26/2015 9:27 AM, Dmitry Olshansky via phobos wrote:
> Agreed. That is my opinion as well, however luck of any attention from you and
> Walter led to the point where we
> need (a) and (b) to work right now and we hacked it (somewhat of speaking for
> the community here, correct me if I'm wrong).
My recommendation was to remove the alias this in DirEntry that tried to turn it
into a string. A DirEntry is not a wrapper for a string, in particular, it does
not support range primitives, which is why the string functions failed when
changed to have InputRange parameters. Adding range primitives to DirEntry would
cause other weird problems, because DirEntry is fundamentally not a range (a
range 'consumes' its data via popFront() which makes no sense for DirEntry).
Yes, that breaks:
DirEntry direntry;
remove(direntry);
which must be rewritten as:
DirEntry direntry;
remove(direntry.name);
and we're not supposed to break existing code. But the alternative, which is
redoing every template that accepts an InputRange, seems an awfully heavy
burden. Even if we do this change pervasively in Phobos, how does that help
anyone else who uses InputRanges?
Tl,dr: the alias this in DirEntry is an abusive bad practice, and should never
have happened.
More information about the phobos
mailing list