• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Lesson 24 Keywords.

Status
Not open for further replies.
Level 11
Joined
Dec 5, 2009
Messages
846
You say this
JASS:
*       true or true and false
*
*           true or true and false
*           true or (false)
*           true
*
*   This expression is supposed to return true
*
*   It returns false

I don't get why it is like that? because further down you also say
JASS:
true or (anything) will always be true
but apparently not, explain please :)
 
Order of logical operations (like order of operations in math)

not
and
or

JASS just totally ignores order of operations, it's like

3+3*3 = 18, when the correct answer is 12 : p.

Something else to test is short circuit logic. Does JASS follow short circuit logic?

true or AddOne()

Then display the variable. If 1 was added, it does not use short circuit logic. If one wasn't added, it does. A good test ;).
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
JASS:
function test1 takes nothing returns boolean
    call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 15, "Test1")
    return true
endfunction

function test2 takes nothing returns boolean
    call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 15, "Test2")
    return true
endfunction

function test3 takes nothing returns boolean
    call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 15, "Test3")
    return true
endfunction

function print takes string s returns nothing
    call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, s)
endfunction

function Trig_aaa_Actions takes nothing returns nothing
    if test1() or test2() or test3() then
    endif
    call print("another")
    if test1() and (test2() or test3()) then
    endif
    call print("another")
    if test1() or test2() and test3() then
    endif
endfunction

//===========================================================================
function InitTrig_aaa takes nothing returns nothing
    set gg_trg_aaa = CreateTrigger(  )
    call TriggerAddAction( gg_trg_aaa, function Trig_aaa_Actions )
    call Trig_aaa_Actions()
endfunction

prints:

Test1
another
Test1
Test2
another
Test1
Test3

so it does short circuit because he didnt run all the functions
 
Level 4
Joined
Jan 27, 2010
Messages
133
JASS just totally ignores order of operations, it's like

3+3*3 = 18, when the correct answer is 12 : p.

While I feel this borders on thread necromancy, I just want to point out that 3+3*3 is indeed 12 in JASS.

JASS:
call BJDebugMsg(I2S(3+3*3)) // 12
 
Status
Not open for further replies.
Top