Michelson: update documentation

This commit is contained in:
Benjamin Canou 2018-06-18 13:24:51 +02:00 committed by Grégoire Henry
parent e70cd5c645
commit d5ee3259db

View File

@ -776,16 +776,37 @@ Operations on strings
~~~~~~~~~~~~~~~~~~~~~
Strings are mostly used for naming things without having to rely on
external ID databases. So what can be done is basically use string
constants as is, concatenate them and use them as keys.
external ID databases. They are restricted to the printable subset of
7-bit ASCII, plus some escaped characters (see section on
constants). So what can be done is basically use string constants as
is, concatenate or splice them, and use them as keys.
- ``CONCAT``: String concatenation.
::
:: string : string : 'S -> string : 'S
:: string list : 'S -> string : 'S
> CONCAT / s : t : S => (s ^ t) : S
> CONCAT / {} : S => "" : S
> CONCAT / { s ; <ss> } : S => (s ^ r) : S
where CONCAT / { <ss> } : S => r : S
- ``SIZE``: number of characters in a string.
::
:: string : 'S -> nat : 'S
- ``SLICE``: String access.
:: nat : nat : string : 'S -> option string : 'S
> SLICE / offset : length : s : S => Some ss : S
where ss is the substring of s at the given offset and of the given length
iff offset and (offset + length) are in bounds
> SLICE / offset : length : s : S => None : S
iff offset or (offset + length) are out of bounds
- ``COMPARE``: Lexicographic comparison.
@ -1462,6 +1483,32 @@ the wild and untyped outside world.
:: bytes : 'S -> option 'a : 'S
- ``CONCAT``: Byte sequence concatenation.
::
:: bytes list : 'S -> bytes : 'S
> CONCAT / {} : S => 0x : S
> CONCAT / { s ; <ss> } : S => (s ^ r) : S
where CONCAT / { <ss> } : S => r : S
- ``SIZE``: size of a sequence of bytes.
::
:: bytes : 'S -> nat : 'S
- ``SLICE``: Bytes access.
:: nat : nat : bytes : 'S -> option string : 'S
> SLICE / offset : length : s : S => Some ss : S
where ss is the substring of s at the given offset and of the given length
iff offset and (offset + length) are in bounds
> SLICE / offset : length : s : S => None : S
iff offset or (offset + length) are out of bounds
- ``COMPARE``: Lexicographic comparison.
::