std.algorithm.remove and principle of least astonishment
spir
denis.spir at gmail.com
Tue Nov 23 01:45:35 PST 2010
On Tue, 23 Nov 2010 00:10:40 -0500
Jesse Phillips <jessekphillips+D at gmail.com> wrote:
> Rainer Deyke Wrote:
>
> > On 11/22/2010 11:55, Andrei Alexandrescu wrote:
> > > http://d.puremagic.com/issues/show_bug.cgi?id=5257
> >
> > I think this bug is a symptom of a larger issue. The range abstraction
> > is too fragile. If even you can't use the range abstraction correctly
> > (in the library that defines this abstraction no less), how can you
> > expect anyone else to do so?
>
> Note that this issue with foreach has been discussed before. The suggested solution was to have infer dchar instead of char (shot down since iterating char is useful and it is simple to add the type dchar). Maybe a range interface (as found in std.string) should take precedence over arrays in foreach? Or maybe foreach should only work with ranges and opApply (that would mean std.array would need imported to use foreach with arrays)?
>
> That wouldn't address your exact issue. I tend to agree with Andrei as you should be coding to the Range interface which will prevent any miss use of char/wchar. On the other hand, why can't I have a range of char (I mean get one from an array, not that I would ever want to)?
>
> Anyway, I agree char[] is a special case, but I also agree it isn't an issue.
This issue may also be interpreted as one more sign that text types in general are special enough to require a distinct (set of) type(s). Which would not prevent freely using *char[] as a plain array (even if I personly cannot imagine what for).
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d
mailing list