Newbie initial comments on D language - scope

Jesse Phillips jessekphillips at gmail.com
Mon Jan 28 18:08:25 PST 2008


On Mon, 28 Jan 2008 20:50:59 -0500, Edward Diener wrote:

> 
> I do not understand what you mean by "return the scoped value". If in D
> I write:
> 
> scope class Foo { ... }
> 
> then why should I have to write, when declaring an instance of the
> class:
> 
> scope Foo g = new Foo();
> 
> as opposed to just:
> 
> Foo g = new Foo();
> 
> The compiler knows that Foo is a scoped class, so there is no need for
> the programmer to repeat it in the object declaration.

He is referring to when you have:

scope class Foo() {}

Foo doThings() {
   Foo cats = new Foo();

   return cats;
}

cats no longer exists after return.



More information about the Digitalmars-d mailing list