On Tuesday, 17 March 2015 at 18:14:48 UTC, Jonathan M Davis wrote:
How long is the ref returned by getFoo even valid? Maybe it
refers to memory
that gets freed on the next line. The compiler can't know.
The problem is not specific to variables, any reference type has
that issue.
On Monday, March 16, 2015 18:46:59 Namespace via Digitalmars-d-learn wrote:
May this be worth of an enhancement request? Or was this already
rejected?
And, no, I want no mutable references such as C++.
Walter has been adamantly against having ref variables like C++ has. They're
a potential
On Tuesday, 17 March 2015 at 09:56:09 UTC, Jonathan M Davis wrote:
On Monday, March 16, 2015 18:46:59 Namespace via
Digitalmars-d-learn wrote:
May this be worth of an enhancement request? Or was this
already
rejected?
And, no, I want no mutable references such as C++.
Walter has been
On 03/17/2015 11:14 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
Or, take this example which (unfortunately) currently compiles:
ref int getBar(ref int bar) @safe
{
return bar;
}
ref int getFoo() @safe
{
int foo;
return getBar(foo);
}
void main()
{
On Tuesday, March 17, 2015 09:59:59 Namespace via Digitalmars-d-learn wrote:
On Tuesday, 17 March 2015 at 09:56:09 UTC, Jonathan M Davis wrote:
On Monday, March 16, 2015 18:46:59 Namespace via
Digitalmars-d-learn wrote:
May this be worth of an enhancement request? Or was this
already
On Monday, 16 March 2015 at 19:20:09 UTC, anonymous wrote:
On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote:
const(Matrix)* m = t.getCurrentModelViewMatrix(); //
currently
}
But IMO it would be a lot nicer if I could store the reference
like this:
ref const(Matrix) m =
Currently, if you want to store a long getter into a variable
without copying it (because it may be a big struct), your only
way is to store it as a pointer:
struct Matrix {
float[16] values= [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
];
}
On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote:
const(Matrix)* m = t.getCurrentModelViewMatrix(); //
currently
}
But IMO it would be a lot nicer if I could store the reference
like this:
ref const(Matrix) m = t.getCurrentModelViewMatrix(); // nicer
[Of course
On Monday, 16 March 2015 at 19:20:09 UTC, anonymous wrote:
On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote:
const(Matrix)* m = t.getCurrentModelViewMatrix(); //
currently
}
But IMO it would be a lot nicer if I could store the reference
like this:
ref const(Matrix) m =