Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Trailing arguments for forall procedure #1038

Closed
x0rb0t opened this issue Aug 3, 2021 · 3 comments
Closed

Feature request: Trailing arguments for forall procedure #1038

x0rb0t opened this issue Aug 3, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@x0rb0t
Copy link

x0rb0t commented Aug 3, 2021

I propose to add the ability to pass additional arguments to the procedure, which is called in the loop forall, this can save gas on reading repeated data in the procedure.
Example:

procedure Procedure(value: ListType, arg1: Type1, arg2: Type2, arg3: Type3)
  (* actions *)
end

transition Transition(list: List ListType)
  arg1 <- state_arg1;
  arg2 <- state_arg2;
  arg3 <- state_arg3;
  forall list Procedure arg1 arg2 arg3
end
@vaivaswatha
Copy link
Contributor

Following up a Telegram conversation, another variant that can be useful is to have an accumulator procedure.

For example: given a list of keys, its values must be fetched from a map field and added up. Right now this can be done using a temporary accumulator field in the procedure used with forall. That's gas expensive though.

@jjcnn

@anton-trunov
Copy link
Contributor

Related issue #577, if we refactor the signature to

procedure Procedure(arg1: Type1, arg2: Type2, arg3: Type3, value: ListType)

@anton-trunov anton-trunov added the enhancement New feature or request label Aug 17, 2022
@jjcnn
Copy link
Contributor

jjcnn commented Oct 17, 2022

Closing, since this duplicates #577 .

@jjcnn jjcnn closed this as completed Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants