December 28, 2014
On Sun, 28 Dec 2014 19:02:59 +0100
Joseph Rushton Wakeling via Digitalmars-d-learn
<digitalmars-d-learn@puremagic.com> wrote:

> A question that suddenly occurred to me, and I realized I didn't know the answer.
> 
> Why is it necessary/desirable to define separate .length and .opDollar methods for custom types?
'because you can't write this:

  auto len = myvar.$;

and it's very tedious to write this:

  auto slc = myvar[myvar.length-5..myvar.length-3];

sure, compiler can use `opDollar` when you requested `length` and there
is no such member. but it adds another quirk into language and may
backstab you eventually. there is nothing hard in adding
`alias length = opDollar;` (or vice versa) to type definition.