On Thursday 23 December 2010 05:22:55 spir wrote: > On Wed, 22 Dec 2010 23:22:56 -0600 > > Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote: > > I'm thinking what to do about iota, which has good features but exacts > > too much cost on tight loop performance. One solution would be to define > > iota to be the simple, forward range that I defined as Iota2 in my > > previous post. Then, we need a different name for the full-fledged iota > > (random-access, has known length, iterates through the same numbers > > forward and backward etc). Ideas? > > I would keep length and add an opIn: if (e in interval) {...}. (I'm unsure > whether it's worth allowing different types for bounds and/or for step; > I'd rather make things simple.) Then, you could call it Interval, what do > you think? > > Note: The result would be very similar to python (x)ranges. D has a > notation for a slightly narrower notion: '..'. Thus, what about: > Interval!int interval = 1..9; > or else: > auto interval = Interval!int(1..9); > ? > > What kind of thingie does "i..j" actually construct as of now?
I believe that the only place that .. works is within []. If an object overrides an opSlice() which takes parameters, then that syntax can be used. I don't believe that it works on its own at all. - Jonathan M Davis