Skip to content

Protocol alpha: Add a MAP instruction for options.

Context

In the Michelson language prior to this MR there is a MAP instruction, which can apply a block of code to elements of a list or a map. There's even a macro to map elements of pairs. The present change makes MAP instruction applicable to options as well. The semantics is similar:

MAP { PUSH nat 3; ADD };

adds 3 to the option nat at the top of the stack if its Some or leaves None otherwise.

Manually testing the MR

The following script in combination with tezos-client run script command can be used to manually test the instruction:

parameter (option nat);
storage nat;
code
  { UNPAIR;
    MAP { ADD; PUSH nat 0 };
    DROP;
    NIL operation;
    PAIR;
  };

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, the Development Version section of CHANGES.md for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Sventimir

Merge request reports

Loading