HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

lambda?

08-23-2009, 06:46 PM#1
Vexorian
meh so with time you grow tired of writing enum functions, meh:

problem is how to fit this with the syntax
Collapse JASS:
function err takes nothing returns nothing
    call ForGroup(meh, call KillUnit(GetEnumUnit () ) )
endfunction


becomes:

Collapse JASS:
function err__1 takes nothing returns nothing
     call KillUnit(GetEnumUnit () )
endfunction

function err takes nothing returns nothing
    call ForGroup(meh, function err__1 )
endfunction


?
Possibly working like that with set and return

if you manage to invent something that would also work with functions with arguments (so they become function pointers instead of code, that would be awesome.
08-23-2009, 07:00 PM#2
Deaod
Collapse JASS:
globals
    unit B=CreateUnit(/* ... */)
endglobals

function A takes nothing returns nothing
local unit b=CreateUnit(/* ... */)
    call ForGroup(G, function KillUnit(B))
    call ForGroup(G, function KillUnit(b))
endfunction
becomes:
Collapse JASS:
globals
    unit B=CreateUnit(/* ... */)
unit ___jasshelper_argument_unit1
endglobals

function prototype_001 takes nothing returns nothing
   call KillUnit(___jasshelper_argument_unit1)
endfunction

function A takes nothing returns nothing
local unit b=CreateUnit(/* ... */)
    set ___jasshelper_argument_unit1=B
    call ForGroup(G, function prototype_001)
    set ___jasshelper_argument_unit1=b
    call ForGroup(G, function prototype_001)
endfunction
08-23-2009, 09:28 PM#3
Seshiro
LAMBDA!

A hug and love to Vex plz! <3
08-23-2009, 09:36 PM#4
Anitarf
Quote:
Originally Posted by Seshiro
A hug and love to Vex plz! <3
Not without optional requirements/code.
Oh, and spell olympics judging. :P
08-23-2009, 10:47 PM#5
Fledermaus
Wouldn't that just kill 1 unit rather than doing something to all units in the group Deaod?
08-23-2009, 10:47 PM#6
Strilanc
How about.... lambda.

Collapse JASS:
call ForGroup(meh, lambda
                       call KillUnit(GetEnumUnit())
                   endlambda)
08-23-2009, 11:39 PM#7
TriggerHappy
How about multiple arguments?

Collapse JASS:
    function omgwtf takes nothing returns nothing
        //some shit
        call ForGroup(group, doshit1::doshit2::doshit3)
    endfunction

Will probably need a better syntax.
08-24-2009, 02:11 AM#8
Deaod
Fledermaus, thats the point. I personally have no need for writing code this short. Passing arguments to code vars, however is a different story.
08-24-2009, 02:42 AM#9
Vexorian
Quote:
Originally Posted by Strilanc
How about.... lambda.

Collapse JASS:
call ForGroup(meh, lambda
                       call KillUnit(GetEnumUnit())
                   endlambda)
I'd rather keep it for one liner functions.

Or maybe extend deaod's idea and go back to this idea:

http://www.wc3c.net/showthread.php?p...7&postcount=24
08-24-2009, 02:01 PM#10
Cheezeman
I'd really prefer the idea of pasing on parameters to a custom function rather than a native, like in that link you added.
Maybe it's easier to manage using a global hashtable with the group's handle-id as parentkey, and the parameter 'number' as childkey?
I have no idea how optimized or buggy this will be though...
08-24-2009, 02:03 PM#11
Vexorian
It sounds slower than the function call, that's for sure.

I could probably not be bullet -proof. Hmnn, did anybody ever try to nest two ForGroups using the same group (but different functions) ? I think wc3 allows it.

Now that I think of it, it is not even possible, there is no GetEnumGroup() native.