[Issue 16551] New: Compile-time delegate parameters should allow "scope"
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Sep 27 02:27:59 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16551
Issue ID: 16551
Summary: Compile-time delegate parameters should allow "scope"
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: eyal at weka.io
Currently, in order to pass scoped delegates and avoid GC, one must pass the
delegates as run-time parameters, with undesirable consequences.
It would be very helpful to allow them to be passed as scoped and in
compile-time.
alias Foo1 = void delegate() @nogc;
alias Foo2 = scope void delegate() @nogc; // <-- this "scope" seems to be
completely ignored!
// Syntax error, why? :(
// void foo(scope Foo1 x)() @nogc;
// This is allowed, but Foo2 is not truly "scope"
void foo(Foo2 x)() @nogc;
void main() @nogc {
int x;
foo!({x+=1;}); // Claims to allocate with the gc, it does not!
}
--
More information about the Digitalmars-d-bugs
mailing list