Jump to content
Sign in to follow this  
ianbanks

Complete Guide to SQF Operator Precedence

Recommended Posts

I've been digging a bit into the SQF grammar lately and came up with:

Hopefully if I've explained it all well enough you should be able to figure out where parenthesis are needed in every situation, without the usual trial and error and long learning process. ;)

Share this post


Link to post
Share on other sites

Very good guide, I was always wondering where to put parenthesis and where not.

BIS should put this guide in their next SITREP!

Share this post


Link to post
Share on other sites
I wish SQF had the += -= and ++ and -- operators :(

What would those do ?

Share this post


Link to post
Share on other sites
What would those do ?

They would be short for:

_value = _value + _right

and:

_value = _value + 1

The += and -= version would be fairly easy to implement (they'd be a trivial change to the assignment part of the SQF grammar), but would still require changing the core language which BIS seems very reluctant to do (and for consistency you would want to introduce over a dozen other versions; *=, /=, &&=, etc).

The ++ and -- operators would probably need a language and parser rewrite, since SQF does not have the concept of an "assignable" expression (an assignable expression such as lvalues in C/C++ , which is where most people know ++ and -- from).

Assignment in SQF isn't an operator, it's a special part of the language grammar. So special that you can do this:

8ball = "black"; hint (currentNamespace getVariable "8ball"); // Hints "black"

(When normally, "8ball" would be the number of "8" token followed by a variable or operator "ball").

Edited by IanBanks

Share this post


Link to post
Share on other sites
I wish SQF had the += -= and ++ and -- operators :(

This so much

EDIT: It's such a pain to write:

while {condition} do
{
//stuff
counter = counter + 1;
};

Edited by DreadedEntity

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×