On Wednesday, 5 January 2022 at 08:58:44 UTC, Dennis wrote:
On Wednesday, 5 January 2022 at 05:38:45 UTC, Tejas wrote:
The entire reason I wanted to get a `ref` was so that I can
avoid the `*` :(
I don't know what the real code behind the reduced example is,
but maybe you can structure your
On Wednesday, 5 January 2022 at 05:38:45 UTC, Tejas wrote:
The entire reason I wanted to get a `ref` was so that I can
avoid the `*` :(
I don't know what the real code behind the reduced example is,
but maybe you can structure your code such that the subsequent
modification `c = 10` happens
On Wednesday, 5 January 2022 at 05:17:10 UTC, Stanislav Blinov
wrote:
It is returned. But initializing `c` with it makes a copy.
Oh...
Wish we had real `ref` ;(
This will mutate `a`:
```
func(a) = 10;
```
Thank you for your help!
On Wednesday, 5 January 2022 at 05:15:30 UTC, Paul Backus wrote:
On Wednesday, 5 January 2022 at 04:35:12 UTC, Tejas wrote:
```d
import std.stdio:writeln;
ref int func(return ref int a){
a = 6; // modifies a as expected
return a;
}
void main(){
int a = 5;
auto c = func(a); // I
On Wednesday, 5 January 2022 at 04:35:12 UTC, Tejas wrote:
```d
import std.stdio:writeln;
ref int func(return ref int a){
a = 6; // modifies a as expected
return a;
}
void main(){
int a = 5;
auto c = func(a); // I expected c to alias a here
c = 10; // Expected to modify a as
On Wednesday, 5 January 2022 at 04:35:12 UTC, Tejas wrote:
```d
import std.stdio:writeln;
ref int func(return ref int a){
a = 6; // modifies a as expected
return a;
}
void main(){
int a = 5;
auto c = func(a); // I expected c to alias a here
c = 10; // Expected to modify a as
```d
import std.stdio:writeln;
ref int func(return ref int a){
a = 6; // modifies a as expected
return a;
}
void main(){
int a = 5;
auto c = func(a); // I expected c to alias a here
c = 10; // Expected to modify a as well
writeln(a); // prints 6 :(
}
```
The