Skip to content

Commit

Permalink
Update string docs to say they're Span (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep authored Feb 18, 2024
1 parent 397e26f commit 71d14a6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tutorial/basic-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,29 @@ work on floats as well, but the usual restrictions apply: you can't mix
different float types, or floats and integers, in the same expression, you have
to convert them.

# Fixed Arrays
# Spans

Fixed arrays are the type of (usually statically allocated) arrays. String
literals are fixed arrays of bytes:
String literals are spans of bytes:

```austral
let str: FixedArray[Nat8] := "Hello, world!";
let str: Span[Nat8, Static] := "Hello, world!";
```

The size of a fixed array can be obtained with the built-in `fixedArraySize`
function, which takes a fixed array and returns a value of type `Index`:
The size of a span can be obtained with the built-in `spanLength` function,
which takes a span and returns a value of type `Index`:

```austral
let size: Index := fixedArraySize("Hello, world!");
let size: Index := spanLength("Hello, world!");
```

Array elements can be accessed through the index operator:
Span elements can be accessed through the index operator:

```austral
let str: FixedArray[Nat8] := "Hello, world!";
let str: Span[Nat8, Static] := "Hello, world!";
printLn(str[0]);
```

If an array index is out-of-bounds, the program aborts.
If an index is out-of-bounds, the program aborts.

### Navigation

Expand Down

0 comments on commit 71d14a6

Please sign in to comment.