foreach and filter

bearophile bearophileHUGS at lycos.com
Wed Apr 11 10:00:41 PDT 2012


Jakob Ovrum:

> Value types with no indirection are implicitly convertible to 
> immutable.
>
> -----------
> void main()
> {
>     int a = 2;
>     immutable int b = a;
> }
> -----------

And far more, even with immutable reference types, in this 
program 'a' has to be immutable, no just const:


int[] foo(immutable int[] a) pure {
     return a.dup;
}
void main() {
     immutable b = foo([1, 2]);
}


There is the desire to extend this idea a bit more, I think Hara 
has something on this.

Bye,
bearophile


More information about the Digitalmars-d mailing list