scilla icon indicating copy to clipboard operation
scilla copied to clipboard

Feature request: Trailing arguments for forall procedure

Open x0rb0t opened this issue 2 years ago • 2 comments

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

x0rb0t avatar Aug 03 '21 12:08 x0rb0t

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

vaivaswatha avatar Aug 12 '21 06:08 vaivaswatha

Related issue #577, if we refactor the signature to

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

anton-trunov avatar Jun 17 '22 14:06 anton-trunov

Closing, since this duplicates #577 .

jjcnn avatar Oct 17 '22 13:10 jjcnn