"Steven Schveighoffer" , dans le message (digitalmars.D.learn:30255), a
écrit :
> On Fri, 21 Oct 2011 11:20:01 -0400, Christophe
> wrote:
>
>> "Daniel Murphy" , dans le message (digitalmars.D.learn:30139), a écrit :
>>> "bearophile" wrote in message
>>> news:j7jepi$prp$1...@digitalmars.com...
On Fri, 21 Oct 2011 11:20:01 -0400, Christophe
wrote:
"Daniel Murphy" , dans le message (digitalmars.D.learn:30139), a écrit :
"bearophile" wrote in message
news:j7jepi$prp$1...@digitalmars.com...
Daniel Murphy:
2)
immutable(int[]) fun() { return new int[]; } // conversion happens
here
"Daniel Murphy" , dans le message (digitalmars.D.learn:30139), a écrit :
> "bearophile" 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
ws: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 misunderstood what I'm saying. The patch I made
im
...
>>>
>>> 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.
>>>
>>
>>
On Tue, 18 Oct 2011 02:40:12 -0400, Daniel Murphy
wrote:
"Steven Schveighoffer" 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* qual
"bearophile" 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 of the
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:
http://d.pu
"Steven Schveighoffer" 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
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
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 to
On Wed, 05 Oct 2011 19:19:37 -0400, bearophile
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 expression (new int[](1u))
of ty
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
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
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 ca
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..
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 (
17 matches
Mail list logo