digitalmars.D.learn - A refinement for pure implementation
- bearophile (16/16) Nov 10 2012 Do you remember if Hara has implemented a patch to allow a2 to be
- Timon Gehr (3/19) Nov 10 2012 It is strongly pure regardless of potential aliasing in the return
- bearophile (8/10) Nov 10 2012 This can't be strongly pure:
- Timon Gehr (3/13) Nov 10 2012 The point was that the code you gave should work even without your
- bearophile (5/7) Nov 10 2012 So my original question was: do you remember if Hara has already
Do you remember if Hara has implemented a patch to allow a2 to be 
immutable?
int[] foo1(int x) pure {
     return null;
}
int[] foo2(string s) pure {
     return null;
}
void main() {
     immutable a1 = foo1(10); // OK
     immutable a2 = foo2("hello"); // currently error
}
The idea behind this is that the type of s is different from the 
return type of foo2, so foo2 is a strongly pure function.
Bye,
bearophile
 Nov 10 2012
On 11/10/2012 03:32 PM, bearophile wrote:
 Do you remember if Hara has implemented a patch to allow a2 to be
 immutable?
 int[] foo1(int x) pure {
      return null;
 }
 int[] foo2(string s) pure {
      return null;
 }
 void main() {
      immutable a1 = foo1(10); // OK
      immutable a2 = foo2("hello"); // currently error
 }
 The idea behind this is that the type of s is different from the return
 type of foo2, so foo2 is a strongly pure function.
 Bye,
 bearophile
It is strongly pure regardless of potential aliasing in the return 
value. This is a bug.
 Nov 10 2012
Timon Gehr:It is strongly pure regardless of potential aliasing in the return value. This is a bug.This can't be strongly pure: int[] foo2(int[] a) pure { a[0]++; return a; } Bye, bearophile
 Nov 10 2012
On 11/10/2012 05:21 PM, bearophile wrote:Timon Gehr:The point was that the code you gave should work even without your proposed enhancement.It is strongly pure regardless of potential aliasing in the return value. This is a bug.This can't be strongly pure: int[] foo2(int[] a) pure { a[0]++; return a; } Bye, bearophile
 Nov 10 2012
Timon Gehr:The point was that the code you gave should work even without your proposed enhancement.So my original question was: do you remember if Hara has already written a patch to fix that bug? :-) Bye, bearophile
 Nov 10 2012








 
  
  
  "bearophile" <bearophileHUGS lycos.com>
 "bearophile" <bearophileHUGS lycos.com>