Static attributes aren' immutable

div0 div0 at users.sourceforge.net
Fri Mar 5 12:10:23 PST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pelle Månsson wrote:
> On 03/05/2010 07:50 PM, bearophile wrote:
>> div0:
>>> putting it in Foo simply puts it in a namespace.<
>>
>> So my (wrong) idea of immutable applied to a struct was that every
>> thing in such namespace becomes immutable (I think this is a bit more
>> intuitive).
>>
>> What do you think of modifying D2 so in a situation like the one I've
>> shown even static arguments become const/immutable? Can this cause
>> troubles to other things?
>>
>> Thank you to you and Lars T. Kyllingstad for the answers.
>>
>> Bye,
>> bearophile
> 
> Immutability (somewhat) guarantees the value will never ever change. The
> static attribute could be changed by a non-immutable instance, and can
> therefore not be immutable. It could be const for the immutable
> instance, but I don't see the gains from it.
> 
> I do, however, see the gains from not being able to access the static
> members through an instance.

Yeah, I *never* access static vars through an instance,
I always use the class name.

Somebody want to post in the main group?

Might be worth a bigger discussion; perhaps somebody can provide a good
use case for access through an instance we're not seeing.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLkWUuT9LetA9XoXwRAjTIAJ9kwfo1mKj4J7ghW+SoEYqMBDu/pACfaJyf
YAfV9JMHUAUfsFWw3e5pTSg=
=/Sfv
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list