DMD 1.025 and 2.009 releases

eao197 eao197 at intervale.ru
Sat Jan 12 02:11:22 PST 2008


On Tue, 01 Jan 2008 12:37:38 +0300, Walter Bright  
<newshound1 at digitalmars.com> wrote:

> New const/invariant/enum in 2.009!

I have tried this sample:

import std.stdio;

class Notifier
   {
     int i;

     this( int i_value )
       {
         i = i_value;
       }
   }

class Message
   {
     public Notifier notifier;

     this( Notifier notifier_object )
       {
         notifier = notifier_object;
       }
   }

void
main()
   {
     void show( Message m )
       {
         writefln( &m.notifier, ": ", m.notifier.i );
       }

     auto m1 = new Message( new Notifier( 1 ) );
     show( m1 );

     auto m2 = new invariant(Message)( new Notifier( 2 ) );
     show( m2 );
     m2.notifier = new Notifier( 3 );
     show( m2 );
   }

and got:

882FF8: 1
882FD8: 2
882FD8: 3

Why m2 is not an invariant object?

-- 
Regards,
Yauheni Akhotnikau



More information about the Digitalmars-d-announce mailing list