[Issue 17934] [scope] scopeness entrypoint for unique/ref-counted missing
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 31 09:19:01 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=17934
Mike Franklin <slavo5150 at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |slavo5150 at yahoo.com
--- Comment #7 from Mike Franklin <slavo5150 at yahoo.com> ---
(In reply to Martin Nowak from comment #0)
> /**
> There seems to be now way to write this functions so
> that the compiler infers the return value as scope.
> */
> List list() @trusted
> {
> return List(malloc(1));
> }
>
> void test() @safe
> {
> Elem elem;
> {
> //scope l = list(); // works with explicit scope
> auto l = list(); // not inferred as scope
> elem = l.front; // escapes, b/c l isn't scoped
> }
> }
Why does `scope` need to be inferred? What's wrong with the user being
required to attribute `scope` to the declaration.
What about having `scope` apply to return values of functions, so `list()`
could be written as `scope List list() @trusted`?
--
More information about the Digitalmars-d-bugs
mailing list