tail const ?

sclytrack via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 30 13:39:40 PDT 2014


On Thursday, 30 October 2014 at 10:28:42 UTC, Simon A wrote:
> I don't know about syntax, but D sure needs first-class support 
> of tail immutability.
>

struct A
{
   float * a;

   void foo() tailconst
   {
      writeln(typeof(a).stringof);  //outputs "const(float) *"
   }
}


class B
{
   float * a;

   void foo() tailconst
   {
      writeln(typeof(this).stringof);  //outputs "tailconst(B)"
      writeln(typeof(a).stringof);     //outputs "const float *"
   }
}

tailconst for struct and classes.

How about this?


*sorry about the previous almost empty post.




More information about the Digitalmars-d mailing list