To help LDC/GDC

Artur Skawina art.08.09 at gmail.com
Tue Apr 9 06:18:24 PDT 2013


On 04/09/13 13:47, Simen Kjærås wrote:
> On Tue, 09 Apr 2013 13:10:16 +0200, Artur Skawina <art.08.09 at gmail.com> wrote:
> 
>> A function that both directly depends on global mutable state (and
>> modifies it) can hardly be called pure. Can you (anybody) give a
>> D "pure" definition that allows for the program that I've posted
>> and still makes "pure" useful?
> 
> Functions that are pure may only mutate mutable state explicitly passed
> to them, or created within.

   struct S;
   int f(S* p) pure;
   S* n();

   int g = 0;
   
   int main() {
      S* s = n();
      f(s);
      return g;
   }

Is main() guaranteed to return '0'?
  
artur


More information about the Digitalmars-d mailing list