ref keys

Jonathan M Davis jmdavisProg at gmx.com
Mon Sep 17 14:33:11 PDT 2012


On Monday, September 17, 2012 23:11:42 Namespace wrote:
> I thought that "new A()" could be implicit immutable. Thanks for
> reporting.

I'm sure that there are places where the compiler theoretically could 
implicitly convert a class or struct instantiated with new to immutable (e.g. 
when it's use to initialize an immutable variable), but it doesn't currently 
work that way. You have to explicitly construct it as immutable. Pretty much 
only built-in value types and structs which are value types can be implicitly 
converted to immutable (and in some cases, the result of a strongly pure 
function can be - at least with arrays).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list