DIP69: problem with scope grammar - need a new keyword

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 09:13:50 PST 2014


On Mon, Dec 08, 2014 at 02:52:52AM -0800, Walter Bright via Digitalmars-d wrote:
> On 12/8/2014 2:44 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
> >On Monday, 8 December 2014 at 10:37:29 UTC, Walter Bright wrote:
> >>Another problem with that is:
> >>
> >>  void func(scope T delegate() dg);
> >
> >Playing the devil's advocate:
> >
> >     void func(scope(T delegate()) dg);
> >     void func(scope(T) delegate() dg);
> 
> Note that:
> 
>     void func(ref T delegate() dg);
> 
> has the same problem. The only way to make dg return a 'ref T' is to
> use an alias:
> 
>     alias ref T delegate() dg_t;
>     void func(dg_t dg);
> 
> or put 'ref' as a postfix:
> 
>      void func(T delegate() ref dg);
> 
> But if the latter solution is used for 'scope', then it interferes
> with 'scope this'.

And once we start writing scope(T), we're back to scope being a type
qualifier (aka type constructor) rather than merely a storage class.


T

-- 
What are you when you run out of Monet? Baroque.


More information about the Digitalmars-d mailing list