[Issue 7177] $ should forward to length by default
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 1 16:11:57 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7177
--- Comment #63 from timon.gehr at gmx.ch 2013-04-01 16:11:54 PDT ---
(In reply to comment #62)
> (In reply to comment #61)
> > (In reply to comment #59)
> > > ...
> > >
> > > Yes, there is a bias - frequency. My core argument is that the vast majority of
> > > ranges simply want $ and length to mean the same thing, and very few need to
> > > have them mean different things.
> >
> > His proposal is to make it work for all ranges.
>
> Not sure I understand. It's possible I am confused. Could you please summarize
> what you mean giving some more context? Thanks.
Your proposal is to make opDollar refer to length whenever there is a length,
auto ref opDollar(R)(auto ref R r) if (is(typeof(r.length))) {
return r.length;
}
by default allowing things like:
int[int] x = [1:0,3:2];
x[$]=1;
assert(x==[1:0,2:1,3:2]);
As far as I understand it, his proposal is to restrict $ to ranges.
auto ref opDollar(R)(auto ref R r) if (isInputRange!R && hasLength!R) {
return r.length;
}
std.range vs. object.d is a separate issue.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list