digitalmars.D - opDollar questions
- monarch_dodra (26/26) Oct 30 2012 1.
- Jonathan M Davis (8/36) Oct 31 2012 The only documentation on it that I'm aware of is in TDPL, and the secti...
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?
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)")
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)?"
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?
Oct 30 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
Oct 31 2012








Jonathan M Davis <jmdavisProg gmx.com>