First class lazy Interval
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Feb 27 05:44:31 PST 2009
Michel Fortin wrote:
> On 2009-02-27 04:43:46 -0500, bearophile <bearophileHUGS at lycos.com> said:
>
>> D2 supports the interval syntax in the foreach:
>> foreach (i; 1..1000) {...}
>>
>> Such intervals are useful in a very large number of situations. So,
>> with the new Range support, it may be useful to allow the interval
>> syntax to be used in other contexts as well.
>> So x..y may become a first-class lazy interval from x to y-1, that can
>> be passed to functions too, etc, and not just used into foreach (the
>> compiler can recognize it, and often optimize it away in many
>> situations, replacing it with a normal for() loop).
>
> I agree that having first-class intervals in the language would make it
> better, especially when you want to pass intervals as function arguments.
I'm having trouble understanding what's wrong with the good old data
types and functions.
Andrei
More information about the Digitalmars-d
mailing list