Skip to content

Commit 179b5e1

Browse files
authored
Update bytes docs in sophia_features.md (#520)
1 parent a1955f9 commit 179b5e1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/sophia_features.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ Sophia has the following types:
545545
| bool | A Boolean | ```true``` |
546546
| bits | A bit field | ```Bits.none``` |
547547
| bytes(n) | A byte array with `n` bytes | ```#fedcba9876543210``` |
548+
| bytes() | A byte array of unspecified size | ```#fedcba9876543210``` |
548549
| string | An array of bytes | ```"Foo"``` |
549550
| list | A homogeneous immutable singly linked list. | ```[1, 2, 3]``` |
550551
| ('a, 'b) => 'c | A function. Parentheses can be skipped if there is only one argument | ```(x : int, y : int) => x + y``` |
@@ -569,6 +570,7 @@ Sophia has the following types:
569570
| bool | `true`, `false` |
570571
| bits | `Bits.none`, `Bits.all` |
571572
| bytes(8) | `#fedcba9876543210` |
573+
| bytes() | `#fedcba9876543210` |
572574
| string | `"This is a string"` |
573575
| list | `[1, 2, 3]`, `[(true, 24), (false, 19), (false, -42)]` |
574576
| tuple | `(42, "Foo", true)` |
@@ -872,9 +874,12 @@ Please refer to the `Char` [library documentation](sophia_stdlib.md#char).
872874

873875
## Byte arrays
874876

875-
Byte arrays are fixed size arrays of 8-bit integers. They are described in hexadecimal system,
876-
for example the literal `#cafe` creates a two-element array of bytes `ca` (202) and `fe` (254)
877-
and thus is a value of type `bytes(2)`.
877+
Byte arrays are to be understood as immutable and continuous arrays of 8-bit integers. They are described in hexadecimal system,
878+
for example the literal `#cafe` creates a two-element array of bytes `ca` (202) and `fe` (254).
879+
880+
The type of a byte array is written as `bytes(n)`, where `n` is the size of the array. For instance,
881+
the type of the literal mentioned above (`#cafe`) is `bytes(2)`, as it consists of two bytes (`ca` and `fe`).
882+
Size information can be also omitted (i.e. `bytes()`) to specify the type of a byte array of arbitrary/unknown length. In other words, for any `n`, `bytes(n)` is a subtype of `bytes()`.
878883

879884
Please refer to the `Bytes` [library documentation](sophia_stdlib.md#bytes).
880885

0 commit comments

Comments
 (0)