Discussion What would you like anonymous functions to look like?

tooltiperror

Super Moderator
Staff member
Just a hypothetical question here.

What would you like vJASS Anonymous functions to look like if we had them?

JASS:

call TimerStart(...,
anonymous function takes nothing returns nothing
    call DestroyTimer(GetExpiredTimer())
endfunction)


That's the only way I could imagine them, but still I'd like to know what people think.
 

Hatebreeder

So many apples
It's be nice if you briefly explained what anonymous functions are, or what you mean.

EDIT: I'm guessing you mean something like private public ?
 

Weep

Godspeed to the sound of the pounding
Well, if they are what I think they are, also ForGroup and maybe ForForce...

I wouldn't even want a function declaration, just something like:
JASS:
local integer id = 'hpea'
set GROUP = GroupEnumSomethingSomething()
call ForGroup(g, 
    if GetUnitTypeId(GetEnumUnit()) == id then
        call KillUnit(GetEnumUnit())
    endif
)

...with variables being autopassed. If that too much, maybe:
JASS:
call TimerStart(t, 1., true,
    callback inherits this, id, t, g
        call Stuff()
    endcallback
)
 

luorax

Invasion in Duskwood
@Hatebreeder
No. Anonymous functions are hmm, anonymous functions :D
The best way to define them is tooltiperror's example: He doesn't define/declare the function, he defines it when he calls it. It doesn't have name, it contains the definition only. That's something like a "local function".
In the real programming languages functions're just like the other object types: there're function pointers, and so on. That's why we can use anonymus functions (as i know)
 

Hatebreeder

So many apples
@Hatebreeder
No. Anonymous functions are hmm, anonymous functions :D
The best way to define them is tooltiperror's example: He doesn't define/declare the function, he defines it when he calls it. It doesn't have name, it contains the definition only. That's something like a "local function".
In the real programming languages functions're just like the other object types: there're function pointers, and so on. That's why we can use anonymus functions (as i know)
I see what you did there :3

This will come in quite handy =P Then I won't need to attach Data to functions indirectly or use a roundabout.
However, just [LJASS] function(....) [/LJASS] is enough. not need for anonymous keyword; if you really want it use the anonymous keyword, please make it "anon function(....)"
 

Lyerae

I keep popping up on this site from time to time.
JASS:

	
<b>@Lyerae</b>
&lt;snip&gt;
But this one look a bit weird. The first one looks better.
JASS:


Well I had used the C-like syntax to make what I had typed easier to read, since reading JASS like that could get a little confusing.
 

Sevion

The DIY Ninja
[ljass]code[/ljass] is a type. It'd be confusing.

@Uberplayer

I know it doesn't. Which is why it'd be a good choice. It won't conflict with anything and will be easier to write (preprocessor-wise).
 

Sevion

The DIY Ninja
No, that idea sucks. The unicorns will never do anything with you :-/

Plus, it uses ForGroup.

But I like that do.

Do want anonymous functions.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
>code is a type. It'd be confusing.

code is a type but it is a type that you [almost] never explicitly declare and use. In that viewpoint it is almost completely useless to the mapper.

Also other languages use the same keyword in different contexts to mean different things which of course [should] makes sense.

I am not saying that "code ... endcode" makes much sense, but it is kinda short and makes little nonsense.
 

Sevion

The DIY Ninja
It would still create confusion.

However little that may be.

When doing something like this, you should create as little conflict and confusion as possible :-/
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Kinda off-topic:

Can some one explain the connection/difference between
anonymous functions and closures? It's a foggy concept for me.
 

tooltiperror

Super Moderator
Staff member
There are two ways to create and kill a unit with KillUnit.

JASS:

local unit u=CreateUnit(...)
call KillUnit(u)

// vs. 

call KillUnit(CreateUnit(...))


The first way is sort of like a normal function. It is declared, then used. Because we set the unit to a variable, we can also keep track of it, or you could think of it as having a label/name, so it is not "anonymous".

An anonymous function would be a function that has no name, and is declared when it needs to be used. Let's say with anonymous functions we could do something like this.

JASS:

//Non-anonymous:
function filter takes nothing returns nothing
    return false
endfunction

call Filter(function filter)

//Anonymous:

call Filter(
anonymous function
    return false
endfunction)


Something like that. In Javascript, it looks better, like this.

JASS:

function init()
{
    /*call*/ function(){
        // anonymous function
    }
}


I commented out "call" because JS doesn't use that keyword.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    that sucks
  • jonas jonas:
    @midnight8 how is it looking
  • midnight8 midnight8:
    meh, me, wife and her friend thaty traveled with us all have covid, seems to be winding down some for me at least. Felt like complete shit, been sleeping a lot, just bieng lazy as hell. I feel like that today has probably been like 11 or 12 days since exposure. Have not had any fever today, and have not taken any meds, so hopefully by monday or tuesday I will be good to go, sadly have passed it on to our teen son, I guess that was pretty much unavoidable
  • The Helper The Helper:
    hope you get to feeling better and get vaccinated my friend
  • midnight8 midnight8:
    I will at some point, but so many vaccinated people still getting it. One of the bands we watch in vegas, all 4 had been vaccinated and are now positive.
  • Ghan Ghan:
    Symptoms?
  • Ghan Ghan:
    I think the symptoms are typically less severe if previously vaccinated.
  • midnight8 midnight8:
    I have had all of the symptoms, taste is slightly starting to come back, but smell, no. Honestly, just been a little miserable, have never felt in any danger from it. Being trapped at home sucks. lol
  • midnight8 midnight8:
    meh, got a little fever again this morning, guess gonna be a few more days
  • The Helper The Helper:
    I went to Comicon this last weekend I hope I dont get it I feel fine and I am not vaccinated and did not wear a mask
  • The Helper The Helper:
    Comicon really was not packed though like it was in the past. I am not really worried though it was the most people I have been around in a year.
  • tom_mai78101 tom_mai78101:
    Still, getting vaccinated is a good idea. We're getting Delta variant spikes here in Boston.
  • The Helper The Helper:
    I am not against vaccination at all I just have a serious procrastination problem I plan on getting vaccinated soon
  • midnight8 midnight8:
    was kinda same with me, I was gonna do it, and life got in the way.
  • midnight8 midnight8:
    we wore mask in some places, but at 118 degrees outside, little rough. :)
  • The Helper The Helper:
    yeah i had another friend in Vegas talking about that heat damn
  • The Helper The Helper:
    Well I do not think I got Covid from the Comicon
    +1
  • tom_mai78101 tom_mai78101:
    Pushed out a new Pokemon Walking algorithm build. With a new system in place, I'll probably start tackling triggers and NPCs,
    +1
  • Varine Varine:
    Is it fucking hot everywhere?
  • Varine Varine:
    What's a pokemon walking algorithm?
  • jonas jonas:
    it's an engine for pokemon games that closely emulates the walking behavior of pokemon red/blue/yellow
  • jonas jonas:
    basically if you wanted to implement pokemon yellow from scratch, and you'd want it to feel as close as possible to the real thing, you'd start with that
  • Varine Varine:
    Like from the Gameboy games? I'm not at all familiar with Pokemon.
  • jonas jonas:
    yeah
  • The Helper The Helper:
    I only played the Pokemon games on the Gamecube and Wii and such not on the portables my kids had all those games but I never really played on the portables. Now that I think about maybe once sooooo long ago.

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome
    Top