On Sunday, 29 May 2016 at 11:16:57 UTC, Dicebot wrote:
On 05/28/2016 09:58 PM, Iakh wrote:
Yeah. It doesn't capture any context. But once it does it
would be an error.
Custom allocators are not very suitable for things like
closures because of undefined lifetime. Even if it was allowed
to
On Sunday, 29 May 2016 at 11:16:57 UTC, Dicebot wrote:
On 05/28/2016 09:58 PM, Iakh wrote:
Yeah. It doesn't capture any context. But once it does it
would be an error.
Custom allocators are not very suitable for things like
closures because of undefined lifetime. Even if it was allowed
to
On 05/28/2016 09:58 PM, Iakh wrote:
> Yeah. It doesn't capture any context. But once it does it
> would be an error.
Custom allocators are not very suitable for things like closures because
of undefined lifetime. Even if it was allowed to replace allocator, you
would be limited to either GC or RC
On Thursday, 26 May 2016 at 21:10:30 UTC, bpr wrote:
On Thursday, 26 May 2016 at 18:53:35 UTC, Iakh wrote:
Functions with lambdas cannot be @nogc as far as they
allocates closures.
Counterexample:
// Note that this is NOT a good way to do numerical quadrature!
double integrate(scope double
On Friday, 27 May 2016 at 10:34:38 UTC, Kagamin wrote:
On Thursday, 26 May 2016 at 18:53:35 UTC, Iakh wrote:
void g() @nogc
{
catch scope(void);
int[N] arr = [/*...*/];
arr[].sort!((a, b) => a > b);
}
This compiles just fine and doesn't allocate:
void g() @nogc
{
int[2] arr =
On Thursday, 26 May 2016 at 18:53:35 UTC, Iakh wrote:
void g() @nogc
{
catch scope(void);
int[N] arr = [/*...*/];
arr[].sort!((a, b) => a > b);
}
This compiles just fine and doesn't allocate:
void g() @nogc
{
int[2] arr = [5,4];
arr[].sort!((a, b) => a > b);
}
On Thursday, 26 May 2016 at 18:53:35 UTC, Iakh wrote:
Functions with lambdas cannot be @nogc as far as they allocates
closures.
Counterexample:
// Note that this is NOT a good way to do numerical quadrature!
double integrate(scope double delegate(double x) @nogc f,
double
Functions with lambdas cannot be @nogc as far as they allocates
closures.
And the way lambdas works is completely different from C++ way.
In D using
lambda we define how some part of "stack" frame allocates. So in
some aspect
closure allocation is property of a function. So we need a way
to