The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
&& operator
Author Message
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #1
&& operator
Hello ,

just a quick question , is the operator && short-circuited in sphere ?
04-03-2012 11:18 PM
Find all posts by this user Like Post Quote this message in a reply
dagger4k
Journeyman
*

Posts: 194
Likes Given: 1
Likes Received: 12 in 12 posts
Joined: Mar 2012
Reputation: 0



Post: #2
RE: && operator
what do you mean by short circuited
04-03-2012 11:31 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #3
RE: && operator
Like

a = 0
b = 1
if (a != 0 && b ==1 )

If the && operator is short circuited ,the second operation (b==1 ) doesn't get evaluated because the first operation is false .
Instead , if the && operator is not short circuited , the second operation will be anyway executed even if it's useless to evaluate it .

Better explained Big Grin http://en.wikipedia.org/wiki/Short-circuit_evaluation
(This post was last modified: 04-03-2012 11:43 PM by darksun84.)
04-03-2012 11:40 PM
Find all posts by this user Like Post Quote this message in a reply
Shaklaban
Master
**

Posts: 378
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Mar 2012
Reputation: 8

DOT

Post: #4
RE: && operator
i think it is not, im tested it like this:
Code:
[function short_bla]
ref1=06f82 //uid of a character
if ((<ref1.isitem>) && (<ref1.type> = t_weapon_fence)) //this line gives error, this means second statement is controlled even first one is false
  
endif
04-04-2012 12:57 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
ShiryuX
Journeyman
*

Posts: 249
Likes Given: 1
Likes Received: 19 in 14 posts
Joined: Mar 2010
Reputation: 4



Post: #5
RE: && operator
It is not.

Code:
[function fTest]
local.testing = 0
if ( <local.testing> && <f_test> )
serv.log yay!
endif

[function f_test]
serv.log we're firing this anyway
return 1

Code:
12:06:(sphere_test.scp,19)we're firing this anyway

Got to admit something:
1. I forgot to add < > to f_test
2. Instead of return 1, I used return true.
3. Probably, this is because I got used to C++ Tongue
(This post was last modified: 04-04-2012 01:11 AM by SystemMod.)
04-04-2012 01:07 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 3 Guest(s)