[Issue 7177] $ should forward to length by default

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 21 11:22:49 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=7177



--- Comment #28 from monarchdodra at gmail.com 2013-03-21 11:22:48 PDT ---
(In reply to comment #27)
> > How does it do anything to make ranges more complex?
> 
> Because it makes yet another thing that range-based functions must test for. We
> arguably have too many such traits already. The _only_ reason I see to not
> require that opDollar work with ranges which have slicing and finite
> random-access ranges is the fact that the change will break code. IMHO,
> everything else about it is exactly the right thing to do.

Yeah, exactly what he said. Having yet another trait means:
a) Don't test the trait and ignore opDollar.
b) Test the trait and fork the code even more.

Neither is satisfactory. Requiring RA and slicing to support $ is just what
makes sense and is natural. Making it "yet another trait" would be wrong.
Just... wrong.

What we are trying to do is:
a) Not break code by adding more to the requirements.
b) Provide an external solution for ranges that don't define opDollar (because
for a range, defining opDollar as an alias of length IS natural).

And as long as we don't have this, $ is just as good as useless in generic
code. The only place I know of where we use it is for popFrontN, and even then
we jump through hoops to get it to work.

Getting this ER to work, in one way or another, is very important for the
natural and generic usage of ranges. Right around now, I'm kind of wishing I
had kept my mouth shut, because I too have been waiting for this for a while :/

-- 
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