Implicit cast to immutable

bearophile bearophileHUGS at lycos.com
Wed Oct 5 17:23:50 PDT 2011


Andrej Mitrovic:

> Maybe:
> 
> immutable(int[]) foo(in int[] x) pure {
>    return new immutable(int[1]);
> }
> 
> void main() {}

I'd like to know why the code in my original post doesn't compile. I suspect it's a DMD bug, but I am not sure.


> Or does this have something to do with implicit casts to immutable for
> pure functions?

Right.


> I'm only vaguely familiar with pure..

I suggest you to use purity more and more in D, because it helps and with the recent bug fixes it is also becoming usable in D (but there are some significant problems left, example: map/filter are not pure yet).

Bye and thank you,
bearophile


More information about the Digitalmars-d-learn mailing list