Proposal: Relax rules for 'pure'

Don nospam at nospam.com
Wed Sep 22 08:05:20 PDT 2010


Steven Schveighoffer wrote:
> On Wed, 22 Sep 2010 09:16:37 -0400, Jason House 
> <jason.james.house at gmail.com> wrote:
> 
>> I think you need to forbid access to shared state as well. It's 
>> possible to allow it if a strongly pure function calls a weakly pure 
>> function in an object that it created, but that seems unnecessarily 
>> complex.
> 
> Yes, I think Don expected that you shouldn't be allowed to access 
> shared, but I don't think he specifically stated it.  I do think it 
> needs to be added as a specific rule.

You're right, it should be explicitly stated.

> 
>> Actually, that makes me wonder: can constructors be marked pure?
> 
> Of course!  A constructor just allocates memory and initializes it.  A 
> pure constructor would not be allowed to access global or shared 
> variables either.
> 
> -Steve


More information about the Digitalmars-d mailing list