opDollar questions

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 31 00:32:47 PDT 2012


On Tuesday, October 30, 2012 08:01:58 monarch_dodra wrote:
> 1.
> I saw a pull request that claimed to "fix" opDollar go through
> recently. Does this mean we can now use it correctly? In both
> r[0..$];
> and
> r[$..$];
> forms?

It seems to work from the little playing around with it that I've done.

> 2.
> Would it be OK if I asked for a little implementation tutorial on
> opDollar, and how to correctly write one when dimensions can get
> involved? I'm unsure how it is done (I've seen both
> "opDollar(size_t dim)()" and "opDollar(size_t dim)")

The only documentation on it that I'm aware of is in TDPL, and the section 
isn't very long.

> 3.
> One last question: The possibility of using opDollar to slice a
> range to its end (in particular, infinite ranges) has been
> brought up more than once. May I request we have a normalized
> type:
> struct InfDollar{}
> 
> Or something inside range.d?
> 
> This way, infinite ranges would not have to invent a new token
> themselves just for this, and simply implement "auto
> opSlice(size_t i, InfDollar dol)?"

Sounds reasonable to me.

> 4. In the context of the above question, would it be possible to
> implement opDollar simply as an enum?
> enum opDollar = InfDollar.init;
> Or would that be a problem?

I very much doubt it, but I don't know. You'll have to try it and see if it 
works.

- Jonathan M Davis


More information about the Digitalmars-d mailing list