Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Oracle
Apprentice


Joined: 29 May 2002
Posts: 121

PostPosted: Tue Sep 23, 2003 8:11 pm   

Difference between = and ==
 
Need some clarification between the two different type of expressions.

I know in C and Java, = expression usually translates to an assignment statement.

I also know == is used in comparison.

So, I was looking in the manual for details on how either is used in Zmud and can only find about the = expression.

Any comments on ==?

Thanks.
Reply with quote
Talahaski
Enchanter


Joined: 10 Oct 2000
Posts: 656
Location: USA

PostPosted: Tue Sep 23, 2003 8:41 pm   
 
I'm not familar with the use of == in zmud. = can be an assignment if used like variablex='something' or = can be a compairison if used within a IF like #if (@var1='something') {dosomething}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue Sep 23, 2003 9:45 pm   
 
The only difference I'm aware of, through version 6.62, is that = is documented and == is not. Otherwise, they seem to be interchangeable. I recommend using the documented one.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Sep 24, 2003 7:46 pm   
 
As LightBulb mentioned, in an #IF or %if expression, == is the same as =. I added == so that people used to C wouldn't have any trouble, but = is the documented equality test in zMUD.

The use of = as assignment within an IF statement in C (and other C-based languages) is one of the things that I've always hated about C. Being able to change the value of a variable within an expression test produces hard-to-support code in my opinion. Even though Pascal still distinguishes between the two operations using := for assignment and = for equality test, at least they don't allow := to be used within an expression.

In zMUD, the issue is somewhat historical. For a long time, zMUD did not have any assignment operator at all. The = was always used for equality testing, the == was added for C users, and #VAR was used for assignment. Then, in one of the later versions of zMUD, the A=B syntax was added as a shortcut for "#VAR a b" to provide assignment like in other languages. I could have chosen to implement this as A:=B like in Pascal, but went with the simplier syntax to parse.

Probably more than you wanted to know about = in zMUD Smile
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net