diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-04 18:29:09 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-04 18:29:09 -0400 |
| commit | 7b735ab6fc3e0bb368f1ca484168eaefbbe3ce9c (patch) | |
| tree | 4a7c78bb0967b8fbc1042d901cf0346705d9d0d8 /examples | |
| parent | 0b8074154e2671691050bdb3bcb33245625a056c (diff) | |
Misc fixes
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/commands/commands.tm | 4 | ||||
| -rw-r--r-- | examples/http-server/connection-queue.tm | 2 | ||||
| -rw-r--r-- | examples/http/http.tm | 2 | ||||
| -rw-r--r-- | examples/patterns/README.md | 2 | ||||
| -rw-r--r-- | examples/random/random.tm | 2 | ||||
| -rw-r--r-- | examples/tomo-install/tomo-install.tm | 2 | ||||
| -rw-r--r-- | examples/vectors/vectors.tm | 4 |
7 files changed, 9 insertions, 9 deletions
diff --git a/examples/commands/commands.tm b/examples/commands/commands.tm index ddd04d7b..170e45bc 100644 --- a/examples/commands/commands.tm +++ b/examples/commands/commands.tm @@ -11,12 +11,12 @@ enum ExitType(Exited(status:Int32), Signaled(signal:Int32), Failed): when e is Exited(status): return (status == 0) else: return no - func or_fail(e:ExitType, message=none:Text): + func or_fail(e:ExitType, message:Text?=none): if not e:succeeded(): fail(message or "Program failed: $e") struct ProgramResult(stdout:[Byte], stderr:[Byte], exit_type:ExitType): - func or_fail(r:ProgramResult, message=none:Text -> ProgramResult): + func or_fail(r:ProgramResult, message:Text?=none -> ProgramResult): when r.exit_type is Exited(status): if status == 0: return r diff --git a/examples/http-server/connection-queue.tm b/examples/http-server/connection-queue.tm index 362dab7b..84f92362 100644 --- a/examples/http-server/connection-queue.tm +++ b/examples/http-server/connection-queue.tm @@ -12,7 +12,7 @@ struct ConnectionQueue(_connections:@[Int32]=@[], _mutex=pthread_mutex_t.new(), func dequeue(queue:ConnectionQueue -> Int32): - conn := none:Int32 + conn : Int32? = none queue._mutex:lock() diff --git a/examples/http/http.tm b/examples/http/http.tm index ee1b8c75..ce74d010 100644 --- a/examples/http/http.tm +++ b/examples/http/http.tm @@ -93,7 +93,7 @@ func put(url:Text, data="", headers=["Content-Type: application/json", "Accept: func patch(url:Text, data="", headers=["Content-Type: application/json", "Accept: application/json"] -> HTTPResponse): return _send(PATCH, url, data, headers) -func delete(url:Text, data=none:Text, headers=["Content-Type: application/json", "Accept: application/json"] -> HTTPResponse): +func delete(url:Text, data:Text?=none, headers=["Content-Type: application/json", "Accept: application/json"] -> HTTPResponse): return _send(DELETE, url, data, headers) func main(): diff --git a/examples/patterns/README.md b/examples/patterns/README.md index 2fb17391..9e9d8601 100644 --- a/examples/patterns/README.md +++ b/examples/patterns/README.md @@ -332,7 +332,7 @@ not match the pattern. >> "123 boxes":pattern_captures($Pat"{int} {id}") = ["123", "boxes"]? >> "xxx":pattern_captures($Pat"{int} {id}") -= none:[Text] += none ``` --- diff --git a/examples/random/random.tm b/examples/random/random.tm index 0a0167ac..95d2f9fe 100644 --- a/examples/random/random.tm +++ b/examples/random/random.tm @@ -25,7 +25,7 @@ func _os_random_bytes(count:Int64 -> [Byte]): } struct RandomNumberGenerator(_chacha:chacha_ctx, _random_bytes:[Byte]=[]; secret): - func new(seed=none:[Byte], -> @RandomNumberGenerator): + func new(seed:[Byte]?=none, -> @RandomNumberGenerator): ctx := chacha_ctx.from_seed(seed or _os_random_bytes(40)) return @RandomNumberGenerator(ctx, []) diff --git a/examples/tomo-install/tomo-install.tm b/examples/tomo-install/tomo-install.tm index c705af12..0be05619 100644 --- a/examples/tomo-install/tomo-install.tm +++ b/examples/tomo-install/tomo-install.tm @@ -40,7 +40,7 @@ func main(paths:[Path]): say("Already installed: $url") skip - alias := none:Text + alias : Text? = none curl_flags := ["-L"] if github := url_without_protocol:pattern_captures($Pat"github.com/{!/}/{!/}#{..}"): user := github[1] diff --git a/examples/vectors/vectors.tm b/examples/vectors/vectors.tm index 3f07e500..f978d3d1 100644 --- a/examples/vectors/vectors.tm +++ b/examples/vectors/vectors.tm @@ -19,7 +19,7 @@ struct Vec2(x,y:Num): func divided_by(v:Vec2, divisor:Num->Vec2; inline): return Vec2(v.x/divisor, v.y/divisor) func length(v:Vec2->Num; inline): - return (v.x*v.x + v.y*v.y)!:sqrt() + return (v.x*v.x + v.y*v.y):sqrt() func dist(a,b:Vec2->Num; inline): return a:minus(b):length() func angle(v:Vec2->Num; inline): @@ -58,7 +58,7 @@ struct Vec3(x,y,z:Num): func divided_by(v:Vec3, divisor:Num->Vec3; inline): return Vec3(v.x/divisor, v.y/divisor, v.z/divisor) func length(v:Vec3->Num; inline): - return (v.x*v.x + v.y*v.y + v.z*v.z)!:sqrt() + return (v.x*v.x + v.y*v.y + v.z*v.z):sqrt() func dist(a,b:Vec3->Num; inline): return a:minus(b):length() func norm(v:Vec3->Vec3; inline): |
