May 13, 2017
https://issues.dlang.org/show_bug.cgi?id=16551

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Eyal from comment #0)
> // Syntax error, why? :(
> // void foo(scope Foo1 x)() @nogc;

It's because 'scope' is not a type constructor, it is a storage class.

> alias Foo2 = scope void delegate() @nogc; // <-- this "scope" seems to be completely ignored!

This is because 'scope' here applies to what the delegate does with its 'this' pointer (aka 'context' pointer, 'frame' pointer, 'dynamic link' pointer). foo() could still store the delegate into a global variable, hence allowing it to escape and hence a closure is necessary.

Currently, the following compiles successfully:

---
alias Foo2 = void delegate() @nogc; // no 'scope' necessary here

void foo(scope Foo2 x) @nogc { }

void main() @nogc {
    int x;
    foo({x+=1;});
}
---

Turning on inlining should remove the overhead of making it a runtime parameter.

Adding 'scope' as an allowed storage class for template alias parameters would be a significant and complex extension, and would need a strong use case rationale. This would need to have a DIP created for it.

--
December 08, 2021
https://issues.dlang.org/show_bug.cgi?id=16551

Stanislav Blinov <stanislav.blinov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |stanislav.blinov@gmail.com
         Resolution|---                         |LATER

--