On Thu, 23 Dec 2010 05:29:32 -0800
Jonathan M Davis <jmdavisp...@gmx.com> wrote:

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

;-) There's also
        foreach(n ; i..j) {...}
Precisely, that's what I was thinking at when stating that D has a notation for 
a very close (but narrower) notion. Slicing is related, but much farther since 
it does not necessarily resuire iteration (bit it's result does allow it).
Note: Iota is right-side exclusive like i..j . (I've just been caught by this 
trap ;-)

>  I don't believe that it works on its own at all.

Certainly not. This would be a syntactic addition. The reason why I asked what 
"i..j" currently yield --if it yield anything (could just rewrite).


denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com

Reply via email to