Discussion What would you like anonymous functions to look like?

SerraAvenger

Cuz I can
Reaction score
234
ruby does it like this:
Code:
{|arguments in here| code in here}
something like this might be JASS-Y syntax:
Code:
function _ takes .... returns ...
...
endfunction

call this(...)
could be nice in order to allow for recursion.

EDIT:

Kinda off-topic:

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

A closure is a piece of code that is closed over the environment/bindings, which means that it kinda carries a copy of all the states from where it was. If the closure is executed somewhere else, it will still be bound to the initial bindings, even if the bindings have changed in the mean time.
An anonymous function is a function without a name and usually only makes sense where functions are first class values. In current implementations, anonymous functions often are closures, too; But that's not necessary for it to be considered an anonymous function. You can have an anonymous function that doesn't "copy" its bindings.

In Java, anonymous functions are implemented via anonymous classes and are not closures. You can make them such though by adding fields to your anonymous class and setting those fields whenever you instantiate the class.
 
General chit-chat
Help Users

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top