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
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() {
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
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
...
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* qualifies.
I think you've misunderstood what I'm saying. The patch I made
implemented
two ways
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* qualifies.
I think you've
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
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:
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
{
return new int[1];
}
void main() {
immutable x = foo([1, 2, 3].idup);
}
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* qualifies.
Qualifying means the return
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
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
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
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
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 expression (new int[](1u)) of type
int[] to immutable(int[])
This program instead compiles
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..
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
17 matches
Mail list logo