You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following is the smallest example of a lambda I could come up with (calling foo() and calling baz() will have the same result)
contract "lambdaTest" {
// this will be our lambda
define public @foo() {
entry:
ret 1234
}
// In a real world setting, this function would return a different lambda based on some condition
define public @bar(){
entry:
%this = call @iele.address()
%f = calladdress @foo at %this
ret %f
}
// fetch which lambda to use from bar and then call it
define public @baz() {
entry:
%f = call @bar()
%this = call @iele.address()
%gas = call @iele.gas()
%status, %result = call %f at %this () send 0, gaslimit %gas
ret %result
}
define @init() {
entry:
ret void
}
}
Unfortunately this is not very pretty because
Calladdress requires an "at" instead of implicitly using @iele.address()
You cannot use call on a register. You must use call at
I don't know why these restrictions exist.
Anyways this is a cool feature and it's much prettier than what you have to do in Solidity which involves mangling byte arrays 👍
The text was updated successfully, but these errors were encountered:
SebastienGllmt
changed the title
Facilitate Creation of Lambdas?
Facilitate Creation of Function Pointers / Lambdas?
Aug 30, 2018
I don't have time to investigate this immediately, but I will look into it sometime in the next couple days. In the meantime, if you want to help, can you tell me what went wrong when you tried to do a local call on a function pointer?
The following is the smallest example of a lambda I could come up with (calling
foo()
and callingbaz()
will have the same result)Unfortunately this is not very pretty because
Calladdress
requires an "at" instead of implicitly using@iele.address()
call
on a register. You must usecall at
I don't know why these restrictions exist.
Anyways this is a cool feature and it's much prettier than what you have to do in Solidity which involves mangling byte arrays 👍
The text was updated successfully, but these errors were encountered: