neo-go icon indicating copy to clipboard operation
neo-go copied to clipboard

Lambda support in compiler

Open fyrchik opened this issue 4 years ago • 0 comments

This is a tracking issue for the tasks related to lambda support. Things, that need to be tested/implemented or made explicitly not supported:

I'd personally support only 4-th and as it can simplify contract code via some dynamic dispatching. Though even now this can be modelled via switch/if. 5-th can be useful for debugging. All others are too complex to be used in any reasonable smart-contract.

  1. Declaring lambda inside of another lambda.
a := func(...) {
  b := func(...) {
  }
}
  1. Calling lambda function recursively.
var a func(int)
a = func(x int) {
  ...
  return a(x-1)
}
  1. Redefining function variable inside of a function assigned to it.
var a func(int)
a = func(x int) {
  ...
  if ... {
    a = ...
  }
}
  1. Assigning a function to a function variable
func f(int) {...}
...
var a func(int) = f
  1. Interop for calling arbitrary []byte slice. This includes e.g. checking if all JMP*s are hygienic, i.e. do not leave provided script.

fyrchik avatar May 07 '20 14:05 fyrchik