FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Class Invariants

 
Post new topic   Reply to topic     Forum Index -> Descent
View previous topic :: View next topic  
Author Message
kihjin



Joined: 28 Dec 2006
Posts: 18

PostPosted: Fri Sep 14, 2007 7:26 pm    Post subject: Class Invariants Reply with quote

Hi-

The following piece of code renders an "error" on assert(true); but dmd compiles it just fine. Does Descent lack class invariant syntax support?

Code:
module Test;

class Test
{
   this()
   {
   }
   
   invariant
   {
      assert(true); // Shows as an error
   }
}


I can deal with the error, I just wanted to see if this was an issue with Descent or if I've got something messed up locally.
Back to top
View user's profile Send private message
asterite



Joined: 01 Jun 2006
Posts: 235
Location: Buenos Aires, Argentina

PostPosted: Sat Sep 15, 2007 7:39 am    Post subject: Reply with quote

If youn compile that code with DMD 2.x you'll get that error. I guess you are compiling with DMD 1.x. If you are using DMD 1.x, go to the project's properties and in the D Compiler option select 1.x.

Also, if you generally develop in DMD 1.x, you can apply this setting to all projects by going to Windows -> Prefereces -> D -> Compiler and selecting 1.x.

In 2.x, you need to write:

invriant() {
assert(true);
}

because "invariant" in 2.x is also a modifier.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kihjin



Joined: 28 Dec 2006
Posts: 18

PostPosted: Sat Sep 15, 2007 8:15 am    Post subject: Reply with quote

Ahhh. So invariant requires ()

I've been using the D docs that came with the DMD compiler locally. They are quicker to load than the ones on digitalmars.com. The class.html I have shows the invariant blockstatement without (), however on digitalmars' page http://www.digitalmars.com/d/class.html#Invariant it clearly shows invariant how you described.
I guess the packaged documentation needs to be updated.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Descent All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group