Component Programming in D
jerro
a at a.com
Tue Oct 2 23:18:16 PDT 2012
On Wednesday, 3 October 2012 at 06:15:32 UTC, jerro wrote:
>> So I think the next *big* step from here, in D3 or some other
>> D-derived
>> language, would be easing the creation of ranges. For example,
>> a
>> special low-boilerplate syntax for creating bidirectional and
>> random-access ranges. Or for input (or maybe even forward)
>> ranges, a
>> C#-style compile-time transformation of a generator function
>> into a
>> range (With input ranges, you can technically get around
>> needing source
>> transformation right now in D2 using fibers, but that has too
>> much runtime overhead to be used as a general solution).
>
> I don't think we need language support in order to have an easy
> way to create random access ranges. We could have a function
> that would be used like this:
>
> auto squares = randomAccessRange(len, (size_t i) => i * i);
>
> This probably wouldn't have optimal performance, but wouldn't
> be horribly slow either. Another option would be to have a
> mixin that would generate all other range methods from a method
> that would provide random access to the initial (that is,
> before the first call to popFront or popBack) range and a
> property that would return the length of the initial range.
Never mind, I just realized that is what std.range.sequence
already does.
More information about the Digitalmars-d-announce
mailing list