Lambda support in compiler #356

Open
opened 2025-12-28 17:13:00 +00:00 by sami · 0 comments
Owner

Originally created by @fyrchik on GitHub (May 7, 2020).

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.
Originally created by @fyrchik on GitHub (May 7, 2020). 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. ```golang a := func(...) { b := func(...) { } } ``` 2. Calling lambda function recursively. ```golang var a func(int) a = func(x int) { ... return a(x-1) } ``` 3. Redefining function variable inside of a function assigned to it. ```golang var a func(int) a = func(x int) { ... if ... { a = ... } } ``` 4. Assigning a function to a function variable ```golang func f(int) {...} ... var a func(int) = f ``` 5. Interop for calling arbitrary `[]byte` slice. This includes e.g. checking if all `JMP*`s are hygienic, i.e. do not leave provided script.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#356
No description provided.