Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 07, 2007 Invariants broken with out cast!!! | ||||
---|---|---|---|---|
| ||||
Attachments: | An invariant(int) can be assigned to an invariant(int)*, this wasn't possible in 2.007. Just compile the attach test case. |
December 07, 2007 Re: Invariants broken with out cast!!! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert DaSilva | None of that matters any more. It's all change again, and this time I do believe we've got it right. We can worry about bugs in that next generation behaviour after it's implemented. |
December 07, 2007 Re: Invariants broken with out cast!!! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert DaSilva | On Thu, 06 Dec 2007 20:43:12 -0800, Robert DaSilva wrote:
> An invariant(int) can be assigned to an invariant(int)*, this wasn't
> possible in 2.007. Just compile the attach test case. import std.stdio;
>
> void main()
> {
> invariant(int) a;
> invariant(int)* b = &a; // error in 2.007, ok in 2.008 writeln(*b);
> a = 1;
> // *b = 2; // error
> writeln(*b);
> }
Even if it's broken, the behaviour seems logical to me.
The types aren't different, so why would you need a cast?
Just my 2 cents.
|
December 07, 2007 Re: Invariants broken with out cast!!! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert DaSilva | On Thu, 06 Dec 2007 20:43:12 -0800, Robert DaSilva wrote:
> An invariant(int) can be assigned to an invariant(int)*, this wasn't
> possible in 2.007. Just compile the attach test case. import std.stdio;
>
> void main()
> {
> invariant(int) a;
> invariant(int)* b = &a; // error in 2.007, ok in 2.008 writeln(*b);
> a = 1;
> // *b = 2; // error
> writeln(*b);
> }
Then again, I'd expect *b to be mutable if a is mutable.
Someone care to explain what the correct behaviour should be and why?
|
December 07, 2007 Re: Invariants broken with out cast!!! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denton Cockburn | On Fri, 07 Dec 2007 08:17:34 +0000, Denton Cockburn wrote:
> On Thu, 06 Dec 2007 20:43:12 -0800, Robert DaSilva wrote:
>
>> An invariant(int) can be assigned to an invariant(int)*, this wasn't
>> possible in 2.007. Just compile the attach test case. import std.stdio;
>>
>> void main()
>> {
>> invariant(int) a;
>> invariant(int)* b = &a; // error in 2.007, ok in 2.008 writeln(*b);
>> a = 1;
>> // *b = 2; // error
>> writeln(*b);
>> }
>
> Then again, I'd expect *b to be mutable if a is mutable. Someone care to explain what the correct behaviour should be and why?
Nevermind, I think I got it.
a is a mutable ref to an invariant int.
b is a pointer to an invariant int
thus: *b is an invariant int that cannot be reassigned
|
Copyright © 1999-2021 by the D Language Foundation