Remus

Jacob Carlborg doob at me.com
Wed Nov 21 08:06:31 PST 2012


On 2012-11-21 15:55, Namespace wrote:
> It is a completly restart.

What happened to the elvis-operator. I though that was one of the best 
features. I also like scoped/stack allocated classes.

> Hm, I don't know, a solution for 'final' should be this:
> [code]
> struct Final(T) {
> private:
>      T _val;
>
> public:
>      @disable
>      this();
>
>      this(T val) {
>          this._val = val;
>      }
>
>      @disable
>      ref typeof(this) opAssign(T val);
>
>      @property
>      inout(T) get() inout {
>          return this._val;
>      }
>
>      alias get this;
> }
> [/code]
> If you can write some use cases for this I will think about it.

class Foo
{
     final Object x;
     final Object y;

     this (Object x, Object y)
     {
         this.x = x;
         this.y = y;
     }
}

I used this all the time in D1, when "const" worked like that. Now I 
have to create getters for these variables instead:

class Foo
{
     private Object x_;
     private Object y_;

     this (Object x, Object y)
     {
         this.x = x;
         this.y = y;
     }

     Object x () { return x_; }
     Object y () { return y_; }
}

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list