Static member functions

"Jérôme M. Berger" jeberger at free.fr
Wed Dec 9 11:39:08 PST 2009


Michal Minich wrote:
> Hello Denis,
> 
>> OTOH, if you want to protect yourself from (accidental) global state
>> mutation, you are free to declare your static function as pure:
>>
>> struct X
>> {
>> static int x;
>> static void foo() pure
>> {
>> // x = 3; // error
>> }
>> static void bar()
>> {
>> x = 3; // okay
>> }
>> }
> 
> I was thinking about providing contract to function, that it does not 
> *modify* state, something as half-pure. Anyway, this would be hard to 
> define correctly.
> 
	That's what gcc calls "__attribute__((pure))" (they use 
"__attribute__((const))" for what D calls "pure")

		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20091209/6a56db78/attachment.pgp>


More information about the Digitalmars-d mailing list