RFC: scope and borrowing

via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 29 07:17:22 PDT 2014


On Saturday, 13 September 2014 at 01:49:05 UTC, Manu via 
Digitalmars-d wrote:
> I'm not convinced this is a good change.
> It sounds like you're just trading one problem with another 
> more sinister
> problem...
>

Ok, I thought about it some more. I'm still not convinced 
completely, but I'm warming up to the idea of making scope a type 
modifier. However, Ivan's objections need to be addressed.

Maybe let's start with a list of problems of the type modifier 
way. So far:

* What is ElementType!(ByLineImpl!(char, "\n")) in the example 
from the wiki page [1]?
* Should Unqual!T strip `scope`?

Anything else? How can we solve these problems?

Another argument against storage class is a syntactical ambiguity 
in conncection with methods:

     struct S {
         scope!this int* foo() scope;
     }

It's ambiguous whether any given scope keyword applies to the 
return value or `this`. One could argue though that this is a 
consequence of the general function attribute problem and should 
preferably be fixed there. (`ref` doesn't have this problem 
because it cannot apply to `this`.)

[1] 
http://wiki.dlang.org/User:Schuetzm/scope#scope.21.28const_....29


More information about the Digitalmars-d mailing list