[Issue 8121] "scope ref" is perfectly OK

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Oct 13 19:14:00 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=8121

Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com

--- Comment #6 from Jonathan M Davis <jmdavisProg at gmx.com> ---
Right now, scope does _nothing_ except for delegates, and I'm not sure how well
it's implemented for them. In all other cases, it's essentially a pointless
attribute. It's not even properly defined at this point exactly what scope
should mean. We all have a rough idea of what it should mean - that the
parameter shouldn't escape the scope of the function - but what exactly that
ultimately means has never been properly defined. As such, it really doesn't
matter if scope ref is illegal. Arguably, scope on _anything_ other than a
delegate should be illegal (the same with in, since it's an alias for const
scope), because it does _nothing_ and has yet to be properly defined, meaning
that it may or may not do what you expect once it's been properly defined and
implemented.

So, I think that it's good to take note the compiler currently doesn't allow
scope ref for whatever reason so that that can be taken into account when scope
is finally ironed out, but until then, it really doesn't matter.

I'd strongly argue that if you're using scope on anything other than delegates
right now, you should stop, because it has no effect on your code right now but
very well could later - and not necessarily how you expect.

--


More information about the Digitalmars-d-bugs mailing list