Associative arrays give compile error

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 6 05:17:26 PDT 2010


On Wed, 06 Oct 2010 08:12:28 -0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>
>> Casting to immutable is the only way to create such a beast.
>
> Then maybe we have to improve the language semantics to allow a better  
> solution. See the Transients of Clojure or the larval objects of Java :-)
>
> The compiler may need to test (at compile time) that there's only one  
> reference to the AA and its contents, and turn it into immutable.

Or, we can make array literals (including AA's) immutable, and call it a  
day.

The only thing is that AA literals provide a nice syntax to make  
non-immutable AAs also, and I can't think of a good way to make a library  
function that creates an AA.  Anyone have any ideas?

-Steve


More information about the Digitalmars-d-learn mailing list