Hi All, I'm a bit confused as to how Classes in D are passed in
arguments and returns.
Take this for example:
class MyClass{
int x = 2;
}
And then in app.d
ref MyClass doStuff(){
MyClass mc = new MyClass() // Heap allocation, using new
return mc;
}
The above fails, as "escaping reference
On Sunday, 16 August 2015 at 22:35:15 UTC, Alex Parrill wrote:
On Sunday, 16 August 2015 at 22:31:02 UTC, Brandon Ragland
wrote:
Hi All, I'm a bit confused as to how Classes in D are passed
in arguments and returns.
Take this for example:
class MyClass{
int x = 2;
}
And then in app.d
ref My
On Sunday, 16 August 2015 at 23:31:46 UTC, Ali Çehreli wrote:
On 08/16/2015 04:13 PM, Brandon Ragland wrote:
> That makes more sense. Though it does make the ref method
> signature unclear, as it only applies to literals at this
> point?
As long as the returned object will be valid after the fu
Howdy,
Since Dynamic Arrays / Slices are a D feature, using pointers to
these has me a bit confused...
Consider:
string c2s(int* pos, char[]* file, int l){
char[] s;
for(int i = 0; i < l; i++){
s ~= file[(*pos + i)];
}
return s.dup;
}
Now what
On Monday, 17 August 2015 at 03:07:26 UTC, Adam D. Ruppe wrote:
On Monday, 17 August 2015 at 02:45:22 UTC, Brandon Ragland
wrote:
[...]
Short answer: pointers to slices are usually a mistake, you
probably don't actually want it, but rather should be using a
regular slice instead.
[...]
On Tuesday, 18 August 2015 at 17:44:00 UTC, Xinok wrote:
On Tuesday, 18 August 2015 at 15:51:55 UTC, ixid wrote:
Though sugar seems to be somewhat looked down upon I thought
I'd suggest this- having seen the cartesianProduct function
from std.algorithm in another thread I thought it would be an