I think the "<>" operator should be used as Not Equal To, such as
if(src.A <> 15)
src<<"You lost."
ID:134789
![]() Sep 12 2005, 4:04 pm
|
|
![]() Sep 12 2005, 4:06 pm
|
|
Um, do you know about the ! operator, or known as the "Not" operator. So if(A != 15) world << "Yay, A isn't 15"
|
Strawgate wrote:
I think the "<>" operator should be used as Not Equal To, such as You can use the != operator to do this very thing. if(src.checkVar != magicNumber) src << "Check failed!" ~>Volte |
If it doesn't exist, define it.
#define <> !=
I already use that for && and || #define and && |
Isn't there already a <> operator, and doesn't it already do that? I roughly translate it to "if it isn't that." Unless spies altered my DM help files and defined the operator in my code.
|
Repiv wrote:
That's a horrible habbit. Like spelling "habit" with two Bs? :-) http://gazoot.byond.com/bbash/?quote=136 |
Why? Isn't the whole point of #define to either make it so that you are more comfortable with the code or to make the code smaller?
I don't see how it can do any harm at all. |
It might confuse people who are working in a team, or produce inconsistencies in the code (some people using OR and AND, other using && and ||). Plus, I dunno...in ActionScript, AND and OR are deprecated in favour of && and ||.
|
Jamesburrow wrote:
Why? Isn't the whole point of #define to either make it so that you are more comfortable with the code or to make the code smaller? Not always. There's also using #define to create constant variables. #define generally makes it easier to make changes to constants. |
Audeuro wrote:
#define generally makes it easier to make changes to constants. Nonsense. Since when is this:
#define BLAH 15
easier to change than this? var/const/BLAH=15 If you want to go and make new operators like that, I say go ahead. =) Elation, I don't know much about ActionScript, but I suspect that the "and" and "or" operators were bitwise operators, like "&" and "|". In that case, you'd normally want to use the logical operators, && and ||, which are generally safer for what "and" and "or" are otherwise usually used for (logical operations). |
Elation wrote:
It might confuse people who are working in a team, or produce inconsistencies in the code... horsepuckey- if the 'team' is all on the same page, and your design docs define what the standards are in the code, then there should be little trouble. |
Elation, I don't know much about ActionScript, but I suspect that the "and" and "or" operators were bitwise operators, like "&" and "|". In that case, you'd normally want to use the logical operators, && and ||, which are generally safer for what "and" and "or" are otherwise usually used for (logical operations). Ripped straight from the ActionScript help: Deprecated Flash 4 operators overview The following table lists Flash 4-only operators, which are deprecated in ActionScript 2.0. Do not use these operators unless you are publishing to Flash Player 4 and earlier. Operator Description not Logical NOT and Logical AND or Logical OR |
Crispy wrote:
Audeuro wrote: Nonsense. Since when is this:
#define BLAH 15
easier to change than this? var/const/BLAH=15 In general, people use #define for constants. I'm not talking about in JUST byond, but also in other languages, like C++, etc. In C++, you CAN do "const (type) (varName);" but from what I've seen, a lot more people use #defines for constants. Example, taken straight from my engine: #define LOG_WARNING 0 For loggers, this is the way I've seen them done. Also, there is other situations where I've seen people use const instead. Like, where the type is not an int or a char. |
Nonsense. Since when is this:
#define BLAH 15
easier to change than this? var/const/BLAH=15 Unfortunantly until DM has cool compiler functionality that preprocesses expressions which can be computed at compile time you can't do anything like this with const variables. var But you can easily do this with defines. Though I do agree const variables are better since they are independant of compilation order unlike #defines however some constants you can't really represent cleanly with const because of these restrictions. |