Re: Implicit cast to immutable

2011-10-27 Thread Christophe
Steven Schveighoffer , dans le message (digitalmars.D.learn:30255), a écrit : On Fri, 21 Oct 2011 11:20:01 -0400, Christophe trav...@phare.normalesup.org wrote: Daniel Murphy , dans le message (digitalmars.D.learn:30139), a écrit : bearophile bearophileh...@lycos.com wrote in message

Re: Implicit cast to immutable

2011-10-24 Thread Steven Schveighoffer
On Fri, 21 Oct 2011 11:20:01 -0400, Christophe trav...@phare.normalesup.org wrote: Daniel Murphy , dans le message (digitalmars.D.learn:30139), a écrit : bearophile bearophileh...@lycos.com wrote in message news:j7jepi$prp$1...@digitalmars.com... Daniel Murphy: 2) immutable(int[]) fun() {

Re: Implicit cast to immutable

2011-10-21 Thread Christophe
Daniel Murphy , dans le message (digitalmars.D.learn:30139), a écrit : bearophile bearophileh...@lycos.com wrote in message news:j7jepi$prp$1...@digitalmars.com... Daniel Murphy: 2) immutable(int[]) fun() { return new int[]; } // conversion happens here immutable x = fun(); Bearophile's

Re: Implicit cast to immutable

2011-10-19 Thread Steven Schveighoffer
On Tue, 18 Oct 2011 02:40:12 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.v3h06olweav7ka@localhost.localdomain... That sounds like an incorrect restriction. The implicit cast to immutable should depend on whether the

Re: Implicit cast to immutable

2011-10-19 Thread Daniel Murphy
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.v3lug2q2eav7ka@localhost.localdomain... On Tue, 18 Oct 2011 02:40:12 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message

Re: Implicit cast to immutable

2011-10-19 Thread Steven Schveighoffer
On Wed, 19 Oct 2011 21:39:47 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.v3lug2q2eav7ka@localhost.localdomain... On Tue, 18 Oct 2011 02:40:12 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: Steven

Re: Implicit cast to immutable

2011-10-18 Thread Daniel Murphy
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.v3h06olweav7ka@localhost.localdomain... That sounds like an incorrect restriction. The implicit cast to immutable should depend on whether the function being *called* qualifies, not if the function you are calling *from*

Re: Implicit cast to immutable

2011-10-18 Thread bearophile
Daniel Murphy: 2) immutable(int[]) fun() { return new int[]; } // conversion happens here immutable x = fun(); Bearophile's example is of the second, where it definately matters what the purity of the function is. This is the enhancement request I have written days ago:

Re: Implicit cast to immutable

2011-10-18 Thread Daniel Murphy
bearophile bearophileh...@lycos.com wrote in message news:j7jepi$prp$1...@digitalmars.com... Daniel Murphy: 2) immutable(int[]) fun() { return new int[]; } // conversion happens here immutable x = fun(); Bearophile's example is of the second, where it definately matters what the purity

Re: Implicit cast to immutable

2011-10-17 Thread Steven Schveighoffer
On Sat, 15 Oct 2011 23:05:43 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: The implicit conversion to immutable is only possible inside strongly pure functions. When the parameter is 'in int[]' foo cannot be strongly pure, only const pure. As 'in int[2]' is a value type, the second

Re: Implicit cast to immutable

2011-10-15 Thread Daniel Murphy
The implicit conversion to immutable is only possible inside strongly pure functions. When the parameter is 'in int[]' foo cannot be strongly pure, only const pure. As 'in int[2]' is a value type, the second foo can be strongly pure. 'new' expressions will hopefully be able to be converted

Re: Implicit cast to immutable

2011-10-06 Thread Christophe
bearophile , dans le message (digitalmars.D.learn:29961), a écrit : Andrej Mitrovic: Maybe: immutable(int[]) foo(in int[] x) pure { return new immutable(int[1]); } void main() {} I'd like to know why the code in my original post doesn't compile. I suspect it's a DMD bug, but I

Re: Implicit cast to immutable

2011-10-06 Thread bearophile
Christophe: That is very consistent, so I don't think this should be considered as a bug. There may be an improvement to ask to make the compiler able to check when the cast to immutable is safe, but I don't think there is a bug. The compiler already performs such checks, in this case it

Re: Implicit cast to immutable

2011-10-06 Thread Steven Schveighoffer
On Wed, 05 Oct 2011 19:19:37 -0400, bearophile bearophileh...@lycos.com wrote: Do you know why this program doesn't compile (with DMD 2.056head)? immutable(int[]) foo(in int[] x) pure { return new int[1]; } void main() {} It gives: test.d(2): Error: cannot implicitly convert

Re: Implicit cast to immutable

2011-10-05 Thread Andrej Mitrovic
Maybe: immutable(int[]) foo(in int[] x) pure { return new immutable(int[1]); } void main() {} Or does this have something to do with implicit casts to immutable for pure functions? I'm only vaguely familiar with pure..

Re: Implicit cast to immutable

2011-10-05 Thread bearophile
Andrej Mitrovic: Maybe: immutable(int[]) foo(in int[] x) pure { return new immutable(int[1]); } void main() {} I'd like to know why the code in my original post doesn't compile. I suspect it's a DMD bug, but I am not sure. Or does this have something to do with implicit casts to