On Saturday, 15 October 2016 at 07:55:30 UTC, ketmar wrote:
p.s. compiler doesn't complain each time, only in some
circumstances. i don't remember the exact code now, but some of
it has nothing to do with closures at all -- no std.algo, no
templates with lambda args, etc.
On Saturday, 15 October 2016 at 05:41:05 UTC, Walter Bright wrote:
The problem is the closure is generated when it is expected
that the delegate will survive past the end of the scope (it's
the whole point of a closure). But with a destructor that runs
at the end of the scope, it cannot survive
On 10/14/2016 3:18 AM, Nordlöw wrote:
t_scope.d(23,6): Error: variable t_scope.below.s has scoped destruction, cannot
build closure
https://github.com/dlang/dmd/blob/master/src/toir.d#L820
The problem is the closure is generated when it is expected that the delegate
will survive past the en
On 10/14/16 6:18 AM, Nordlöw wrote:
The following code
import std.algorithm.iteration : filter;
import std.algorithm.mutation : move;
import std.range : iota;
static private struct S
{
import core.memory : GC;
@disable this(this);
this(int x)
{
_ptr = cast(typeof(_ptr)
On Friday, 14 October 2016 at 14:00:53 UTC, ag0aep6g wrote:
As for ways to make this work:
1) You can move s to the heap yourself:
[...]
2) Or you can move it into a struct that gets returned (more
involved):
[...]
3) Put a struct on the heap that acts as the closure:
auto below5(size_
On Friday, 14 October 2016 at 16:37:06 UTC, Nordlöw wrote:
If I remove the explicit dtor from `S` the code compiles. Can
That of course being incorrect D code that leaks memory.
On Friday, 14 October 2016 at 14:00:53 UTC, ag0aep6g wrote:
As for ways to make this work:
1) You can move s to the heap yourself:
auto below3(size_t n, S s = S.init)
{
import std.algorithm.mutation: moveEmplace;
auto onHeap = cast(S*) new ubyte[S.sizeof];
moveEmplace(s, *onHea
On 10/14/2016 12:18 PM, Nordlöw wrote:
import std.algorithm.iteration : filter;
import std.algorithm.mutation : move;
import std.range : iota;
static private struct S
{
import core.memory : GC;
@disable this(this);
this(int x)
{
_ptr = cast(typeof(_ptr))GC.malloc((*_ptr)
On Friday, 14 October 2016 at 10:18:19 UTC, Nordlöw wrote:
t_scope.d(23,6): Error: variable t_scope.below.s ...
Correction, should be:
t_scope.d(23,6): Error: variable t_scope.below1.s ...
The following code
import std.algorithm.iteration : filter;
import std.algorithm.mutation : move;
import std.range : iota;
static private struct S
{
import core.memory : GC;
@disable this(this);
this(int x)
{
_ptr = cast(typeof(_ptr))GC.malloc((*_ptr).sizeof);
*
10 matches
Mail list logo