From d4b10514fbe3afc7229efe74b015a664b52eba33 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 24 Nov 2024 16:36:27 -0500 Subject: Clean up some more null->none renames and fix the documentation. Also change the literal syntax to `NONE:T` instead of `!T` --- test/iterators.tm | 4 ++-- test/optionals.tm | 38 +++++++++++++++++++------------------- test/structs.tm | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/test/iterators.tm b/test/iterators.tm index 2adcab4a..ebb040fd 100644 --- a/test/iterators.tm +++ b/test/iterators.tm @@ -4,7 +4,7 @@ struct Pair(x:Text, y:Text) func pairwise(strs:[Text] -> func(->Pair?)): i := 1 return func(): - if i + 1 > strs.length: return !Pair + if i + 1 > strs.length: return NONE:Pair i += 1 return Pair(strs[i-1], strs[i])? @@ -12,7 +12,7 @@ func range(first:Int, last:Int -> func(->Int?)): i := first return func(): if i > last: - return !Int + return NONE:Int i += 1 return (i-1)? diff --git a/test/optionals.tm b/test/optionals.tm index 84a4a9ca..acefdd2a 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -11,74 +11,74 @@ enum Enum(X, Y(y:Int)): if should_i: return Enum.Y(123) else: - return !Enum + return NONE func maybe_int(should_i:Bool->Int?): if should_i: return 123 else: - return !Int + return NONE func maybe_int64(should_i:Bool->Int64?): if should_i: return Int64(123) else: - return !Int64 + return NONE func maybe_array(should_i:Bool->[Int]?): if should_i: return [10, 20, 30] else: - return ![Int] + return NONE func maybe_bool(should_i:Bool->Bool?): if should_i: return no else: - return !Bool + return NONE func maybe_text(should_i:Bool->Text?): if should_i: return "Hello" else: - return !Text + return NONE func maybe_num(should_i:Bool->Num?): if should_i: return 12.3 else: - return !Num + return NONE func maybe_lambda(should_i:Bool-> func()?): if should_i: return func(): say("hi!") else: - return !func() + return NONE func maybe_c_string(should_i:Bool->CString?): if should_i: return ("hi":as_c_string())? else: - return !CString + return NONE func maybe_channel(should_i:Bool->|Int|?): if should_i: return |:Int|? else: - return !|Int| + return NONE func maybe_thread(should_i:Bool->Thread?): if should_i: return Thread.new(func(): pass) else: - return !Thread + return NONE func main(): >> 5? = 5 : Int? >> if no: - !Int + NONE:Int else: 5 = 5 : Int? @@ -92,7 +92,7 @@ func main(): >> 5? or exit("Non-null is falsey") = 5 : Int - >> (!Int) or -1 + >> (NONE:Int) or -1 = -1 : Int do: @@ -279,13 +279,13 @@ func main(): = 123 : Int # Test comparisons, hashing, equality: - >> (!Int == 5?) + >> (NONE:Int == 5?) = no >> (5? == 5?) = yes - >> {!Int, !Int} + >> {NONE:Int, NONE:Int} = {NONE} - >> [5?, !Int, !Int, 6?]:sorted() + >> [5?, NONE:Int, NONE:Int, 6?]:sorted() = [NONE, NONE, 5, 6] do: @@ -296,7 +296,7 @@ func main(): = 5 do: - >> value := if var := !Int: + >> value := if var := NONE:Int: var else: 0 @@ -310,7 +310,7 @@ func main(): >> opt do: - >> opt := !Int + >> opt := NONE:Int >> if opt: >> opt else: @@ -319,7 +319,7 @@ func main(): >> not 5? = no - >> not !Int + >> not NONE:Int = yes >> [Struct(5,"A")?, Struct(6,"B"), Struct(7,"C")] diff --git a/test/structs.tm b/test/structs.tm index 26b24d62..ae5bec0f 100644 --- a/test/structs.tm +++ b/test/structs.tm @@ -2,11 +2,11 @@ struct Single(x:Int) struct Pair(x,y:Int) struct Mixed(x:Int, text:Text) -struct LinkedList(x:Int, next=!@LinkedList) +struct LinkedList(x:Int, next=NONE:@LinkedList) struct Password(text:Text; secret) struct CorecursiveA(other:@CorecursiveB?) -struct CorecursiveB(other=!@CorecursiveA) +struct CorecursiveB(other=NONE:@CorecursiveA) func test_literals(): >> Single(123) -- cgit v1.2.3