Provide @immutable attribute for first-class citizens and namespaces?

deadalnix deadalnix at gmail.com
Sat Apr 14 06:26:01 PDT 2012


Le 14/04/2012 08:56, Daniel Fitzpatrick a écrit :
> A few languages out there provide immutability by default. I'm on board
> with D not providing it by default, but would it be useful or worth the
> effort to add an @immutable attribute to first class citizens and
> namespaces eg
>
> // All members & fn returns immutable by default in each case
> @immutable module my.ns;
> @immutable class foo { .. }
> @immutable struct bar { .. }
>
> Additionally,
>
> module blah;
> @const import std.algorithm; // All return refs/vals & public members
> from std.algorithm treated as immutable within blah
>
> I hesitated to post this since I haven't done much with D, so I hope I'm
> not insulting anyone (I have great respect for you all - you were very
> helpful when I was trying to learn the language). No idea how hard this
> is. Thoughts?

« immutable: » can't do the trick ?

BTW, this proposal is a bit problematic without a mutable keyword.


More information about the Digitalmars-d mailing list