WurstScript
WurstScript copied to clipboard
Idea to inline functions with multiply returns
I will take this easy fuctions as example:
function meep(boolean b, int i) returns string
if i > 5
return "a"
if b
return "b"
else
return "c"
The function can be put inside jass into a loop, so the keyword exitwhen can be used to simulate returns inside the function to prevent further code execution:
function inlined takes nothing returns nothing
local integer i = 123
local boolean b = true
local string res
loop
if i > 5 then
set res = "a"
exitwhen true
endif
if b then
set res = "b"
else
set res = "c"
exitwhen true
endloop
//use res here
endfunction
This is just an idea, close this if it is pointless.
It is a bit more complicated, since the inlined function could have a return inside a loop. It would work for other functions, though.
I really doubt this would actually change performance.