From 7159e40b4ec0c126d29485abc25c2cdc52991909 Mon Sep 17 00:00:00 2001 From: Matt Garnett <14004106+c-o-l-o-r@users.noreply.github.com> Date: Wed, 7 Aug 2019 16:56:22 -0400 Subject: [PATCH] add container type to table and 0-index the union type definitions --- specs/simple-serialize.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/specs/simple-serialize.md b/specs/simple-serialize.md index 1edb0bca92..1a1ba35b6c 100644 --- a/specs/simple-serialize.md +++ b/specs/simple-serialize.md @@ -62,7 +62,7 @@ * **bitlist**: ordered variable-length collection of `boolean` values, limited to `N` bits * notation `Bitlist[N]` * **union**: union type containing one of the given subtypes - * notation `Union[type_1, type_2, ...]`, e.g. `union[null, uint64]` + * notation `Union[type_0, type_1, ...]`, e.g. `union[null, uint64]` ### Variable-size and fixed-size @@ -78,16 +78,18 @@ For convenience we alias: * `null`: `{}` ### Default values +Assuming a helper function `default(type)` which returns the default value for `type`, we can recursively define the default value for all types. | Type | Default Value | ---- | ------------- | | `uintN` | `0` | | `boolean` | `False` | -| `Vector[type, N]` | `[Default of type] * N]` | +| `Vector[type, N]` | `[default(type)] * N]` | | `Bitvector[boolean, N]` | `[False] * N` | | `List[type, N]` | `[]` | | `Bitlist[boolean, N]` | `[]` | -| `Union[type_1, type_2, ...]` | Default of `type_1` | +| `Union[type_0, type_1, ...]` | `default(type_0)` | +| `Container` | `[default(element) for element in container]` | #### `is_zero`