checkedint call removal

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 11:36:42 PDT 2014


> a way for x and y (that are of the library-defined type SInt) 
> to keep the value range of an ubyte.

Such management of value ranges by library code could also allow 
to modify the implementation of iota to compile this:


void main() {
     import std.range, std.algorithm;
     auto result = iota(20).map!(i => char(i + 'a'));
}


That mimics with library code this program that today compiles 
(thanks to various improvements in foreach range handling:

void main() {
     foreach (immutable i; 0 .. 20)
         char c = char(i + 'a');
}


You can probably special-case iota() in the compiler, to allow 
the first program (because in D the x..y is not first class, 
unfortunately), but if you offer more generic tools usable by 
library code you can use them in many other situations.

Bye,
bearophile


More information about the Digitalmars-d mailing list