aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/colorful/colorful.tm2
-rw-r--r--examples/commands/commands.tm4
-rw-r--r--examples/http-server/connection-queue.tm2
-rw-r--r--examples/http-server/http-server.tm4
-rw-r--r--examples/http/http.tm2
-rw-r--r--examples/ini/ini.tm4
-rw-r--r--examples/learnxiny.tm4
-rw-r--r--examples/log/log.tm2
-rw-r--r--examples/tomo-install/tomo-install.tm4
-rw-r--r--examples/tomodeps/tomodeps.tm10
-rw-r--r--examples/wrap/wrap.tm4
11 files changed, 21 insertions, 21 deletions
diff --git a/examples/colorful/colorful.tm b/examples/colorful/colorful.tm
index d878b662..30f3fc12 100644
--- a/examples/colorful/colorful.tm
+++ b/examples/colorful/colorful.tm
@@ -141,7 +141,7 @@ struct _TermState(
)
func apply(old,new:_TermState -> Text)
- sequences : &[Text] = &[]
+ sequences : &[Text]
_toggle2(sequences, old.bold, old.dim, new.bold, new.dim, "1", "2", "22")
_toggle2(sequences, old.italic, old.fraktur, new.italic, new.fraktur, "3", "20", "23")
_toggle(sequences, old.underline, new.underline, "4", "24")
diff --git a/examples/commands/commands.tm b/examples/commands/commands.tm
index 2dd5aaf7..81c43692 100644
--- a/examples/commands/commands.tm
+++ b/examples/commands/commands.tm
@@ -54,8 +54,8 @@ struct Command(command:Text, args:[Text]=[], env:{Text=Text}={})
if input.length > 0
(&input_bytes).insert_all(input.bytes())
- stdout : [Byte] = []
- stderr : [Byte] = []
+ stdout : [Byte]
+ stderr : [Byte]
status := run_command(command.command, command.args, command.env, input_bytes, &stdout, &stderr)
if inline C : Bool { WIFEXITED(_$status) }
diff --git a/examples/http-server/connection-queue.tm b/examples/http-server/connection-queue.tm
index 29759f38..c56069e1 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 : Int32? = none
+ conn : Int32?
queue._mutex.lock()
diff --git a/examples/http-server/http-server.tm b/examples/http-server/http-server.tm
index b814cdcb..92651ca1 100644
--- a/examples/http-server/http-server.tm
+++ b/examples/http-server/http-server.tm
@@ -17,7 +17,7 @@ use ./connection-queue.tm
func serve(port:Int32, handler:func(request:HTTPRequest -> HTTPResponse), num_threads=16)
connections := ConnectionQueue()
- workers : &[@pthread_t] = &[]
+ workers : &[@pthread_t]
for i in num_threads
workers.insert(pthread_t.new(func()
repeat
@@ -114,7 +114,7 @@ enum RouteEntry(ServeFile(file:Path), Redirect(destination:Text))
return HTTPResponse("Found", 302, headers={"Location"=destination})
func load_routes(directory:Path -> {Text=RouteEntry})
- routes : &{Text=RouteEntry} = &{}
+ routes : &{Text=RouteEntry}
for file in (directory ++ (./*)).glob()
skip unless file.is_file()
contents := file.read() or skip
diff --git a/examples/http/http.tm b/examples/http/http.tm
index 39cbfd6d..29727e6e 100644
--- a/examples/http/http.tm
+++ b/examples/http/http.tm
@@ -8,7 +8,7 @@ struct HTTPResponse(code:Int, body:Text)
enum _Method(GET, POST, PUT, PATCH, DELETE)
func _send(method:_Method, url:Text, data:Text?, headers:[Text]=[] -> HTTPResponse)
- chunks : @[Text] = @[]
+ chunks : @[Text]
save_chunk := func(chunk:CString, size:Int64, n:Int64)
chunks.insert(inline C:Text {
Text$format("%.*s", _$size*_$n, _$chunk)
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm
index 7d53d7e5..c24cb4b9 100644
--- a/examples/ini/ini.tm
+++ b/examples/ini/ini.tm
@@ -11,8 +11,8 @@ _HELP := "
func parse_ini(path:Path -> {Text={Text=Text}})
text := path.read() or exit("Could not read INI file: $\[31;1]$(path)$\[]")
- sections : @{Text=@{Text=Text}} = @{}
- current_section : @{Text=Text} = @{}
+ sections : @{Text=@{Text=Text}}
+ current_section : @{Text=Text}
# Line wraps:
text = text.replace_pattern($Pat/\{1 nl}{0+space}/, " ")
diff --git a/examples/learnxiny.tm b/examples/learnxiny.tm
index 5bf8e69f..31d768eb 100644
--- a/examples/learnxiny.tm
+++ b/examples/learnxiny.tm
@@ -56,7 +56,7 @@ func main()
my_numbers := [10, 20, 30]
# Empty arrays require specifying the type:
- empty_array : [Int] = []
+ empty_array : [Int]
>> empty_array.length
= 0
@@ -120,7 +120,7 @@ func main()
= 0
# Empty tables require specifying the key and value types:
- empty_table : {Text=Int} = {}
+ empty_table : {Text=Int}
# Tables can be iterated over either by key or key,value:
for key in table
diff --git a/examples/log/log.tm b/examples/log/log.tm
index 3763303f..94984b81 100644
--- a/examples/log/log.tm
+++ b/examples/log/log.tm
@@ -3,7 +3,7 @@ use <stdio.h>
timestamp_format := CString("%F %T")
-logfiles : @|Path| = @||
+logfiles : @|Path|
func _timestamp(->Text)
c_str := inline C:CString {
diff --git a/examples/tomo-install/tomo-install.tm b/examples/tomo-install/tomo-install.tm
index fd8b3c40..c7d752ee 100644
--- a/examples/tomo-install/tomo-install.tm
+++ b/examples/tomo-install/tomo-install.tm
@@ -11,7 +11,7 @@ _HELP := "
"
func find_urls(path:Path -> [Text])
- urls : @[Text] = @[]
+ urls : @[Text]
if path.is_directory()
for f in path.children()
urls.insert_all(find_urls(f))
@@ -40,7 +40,7 @@ func main(paths:[Path])
say("Already installed: $url")
skip
- alias : Text? = none
+ alias : Text?
curl_flags := ["-L"]
if github := url_without_protocol.pattern_captures($Pat"github.com/{!/}/{!/}#{..}")
user := github[1]
diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm
index 1181f2be..1e6be615 100644
--- a/examples/tomodeps/tomodeps.tm
+++ b/examples/tomodeps/tomodeps.tm
@@ -16,7 +16,7 @@ func _get_file_dependencies(file:Path -> |Dependency|)
say("Could not read file: $file")
return ||
- deps : @|Dependency| = @||
+ deps : @|Dependency|
if lines := file.by_line()
for line in lines
if line.matches_pattern($Pat/use {..}.tm/)
@@ -36,8 +36,8 @@ func _build_dependency_graph(dep:Dependency, dependencies:@{Dependency=|Dependen
_get_file_dependencies(path)
is Module(module)
dir := (~/.local/share/tomo/installed/$module)
- module_deps : @|Dependency| = @||
- visited : @|Path| = @||
+ module_deps : @|Dependency|
+ visited : @|Path|
unvisited := @|f.resolved() for f in dir.files() if f.extension() == ".tm"|
while unvisited.length > 0
file := unvisited.items[-1]
@@ -58,7 +58,7 @@ func _build_dependency_graph(dep:Dependency, dependencies:@{Dependency=|Dependen
_build_dependency_graph(dep2, dependencies)
func get_dependency_graph(dep:Dependency -> {Dependency=|Dependency|})
- graph : @{Dependency=|Dependency|} = @{}
+ graph : @{Dependency=|Dependency|}
_build_dependency_graph(dep, graph)
return graph
@@ -88,7 +88,7 @@ func _draw_tree(dep:Dependency, dependencies:{Dependency=|Dependency|}, already_
_draw_tree(child, dependencies, already_printed, child_prefix, is_child_last)
func draw_tree(dep:Dependency, dependencies:{Dependency=|Dependency|})
- printed : @|Dependency| = @||
+ printed : @|Dependency|
say(_printable_name(dep))
printed.add(dep)
deps := dependencies[dep] or ||
diff --git a/examples/wrap/wrap.tm b/examples/wrap/wrap.tm
index 303393ee..1a29701f 100644
--- a/examples/wrap/wrap.tm
+++ b/examples/wrap/wrap.tm
@@ -33,7 +33,7 @@ func wrap(text:Text, width:Int, min_split=3, hyphen="-" -> Text)
... and I can't split it without splitting into chunks smaller than $min_split.
")
- lines : @[Text] = @[]
+ lines : @[Text]
line := ""
for word in text.split($/{whitespace}/)
letters := word.split()
@@ -93,7 +93,7 @@ func main(files:[Path], width=80, inplace=no, min_split=3, rewrap=yes, hyphen=UN
(/dev/stdout)
first := yes
- wrapped_paragraphs : @[Text] = @[]
+ wrapped_paragraphs : @[Text]
for paragraph in text.split($/{2+ nl}/)
wrapped_paragraphs.insert(
wrap(paragraph, width=width, min_split=min_split, hyphen=hyphen)