From 0b8074154e2671691050bdb3bcb33245625a056c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 4 Apr 2025 17:06:09 -0400 Subject: First working compile of refactor to add explicit typing to declarations and support untyped empty collections and `none`s --- docs/arrays.md | 2 +- docs/functions.md | 2 +- docs/integers.md | 2 +- docs/operators.md | 2 +- docs/reductions.md | 2 +- docs/sets.md | 2 +- docs/tables.md | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/arrays.md b/docs/arrays.md index e3da6e0e..437ab76f 100644 --- a/docs/arrays.md +++ b/docs/arrays.md @@ -18,7 +18,7 @@ you want to have an empty array, you must specify what type goes inside the arra like this: ```tomo -empty := [:Int] +empty : [Int] = [] ``` For type annotations, an array that holds items with type `T` is written as `[T]`. diff --git a/docs/functions.md b/docs/functions.md index edd1261a..9f95277f 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -82,7 +82,7 @@ func _add(x, y:Int -> Int): return x + y struct add_args(x,y:Int) -add_cache := @{:add_args,Int} +add_cache : @{add_args=Int} = @{} func add(x, y:Int -> Int): args := add_args(x, y) diff --git a/docs/integers.md b/docs/integers.md index d4e2fc3c..6e45f1be 100644 --- a/docs/integers.md +++ b/docs/integers.md @@ -361,7 +361,7 @@ An iterator function that counts onward from the starting integer. **Example:** ```tomo -nums := &[:Int] +nums : &[Int] = &[] for i in 5:onward(): nums:insert(i) stop if i == 10 diff --git a/docs/operators.md b/docs/operators.md index a4b68fa8..a304cf35 100644 --- a/docs/operators.md +++ b/docs/operators.md @@ -75,7 +75,7 @@ first option is to not account for it, in which case you'll get a runtime error if you use a reducer on something that has no values: ```tomo ->> nums := [:Int] +>> nums : [Int] = [] >> (+: nums)! Error: this collection was empty! diff --git a/docs/reductions.md b/docs/reductions.md index 58cfa314..959d9701 100644 --- a/docs/reductions.md +++ b/docs/reductions.md @@ -18,7 +18,7 @@ a runtime check and error if there's a null value, or you can use `or` to provide a fallback value: ```tomo -nums := [:Int] +nums : [Int] = [] sum := (+: nums) >> sum diff --git a/docs/sets.md b/docs/sets.md index 778740a3..740a37f3 100644 --- a/docs/sets.md +++ b/docs/sets.md @@ -21,7 +21,7 @@ nums := {10, 20, 30} Empty sets must specify the item type explicitly: ```tomo -empty := {:Int} +empty : {Int} = {} ``` For type annotations, a set that holds items with type `T` is written as `{T}`. diff --git a/docs/tables.md b/docs/tables.md index f0045ef7..83c80b2b 100644 --- a/docs/tables.md +++ b/docs/tables.md @@ -17,7 +17,7 @@ table := {"A"=10, "B"=20} Empty tables must specify the key and value types explicitly: ```tomo -empty := {:Text=Int} +empty : {Text=Int} = {} ``` For type annotations, a table that maps keys with type `K` to values of type -- cgit v1.2.3