aboutsummaryrefslogtreecommitdiff
path: root/lib/core/io.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-14 15:42:48 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-14 15:43:24 -0800
commitc1c32688a4afc43f6addb99b8b5fa878944a70e3 (patch)
treec886f21b5b08a9053aa74fcba4b241dae5ede76d /lib/core/io.nom
parent2309b696fc34b24f05f6658b94f9105ca8ee76e4 (diff)
Overhaul in progress, mostly working. Moved all the nomsu packages into
lib/, including core/*. Changes to how nomsu environments and importing work.
Diffstat (limited to 'lib/core/io.nom')
-rw-r--r--lib/core/io.nom29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/core/io.nom b/lib/core/io.nom
new file mode 100644
index 0000000..7afe889
--- /dev/null
+++ b/lib/core/io.nom
@@ -0,0 +1,29 @@
+#!/usr/bin/env nomsu -V6.14
+#
+ This file contains basic input/output code
+
+use "core/metaprogramming"
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+(say $message) compiles to:
+ lua> ("
+ if \$message.type == "Text" then
+ return LuaCode("say(", \($message as lua expr), ");");
+ else
+ return LuaCode("say(tostring(", \($message as lua expr), "));");
+ end
+ ")
+
+(say $message inline) compiles to:
+ lua> ("
+ if \$message.type == "Text" then
+ return LuaCode("io.write(", \($message as lua expr), ")");
+ else
+ return LuaCode("io.write(tostring(", \($message as lua expr), "))");
+ end
+ ")
+
+externally (ask $prompt) means:
+ $io.write $prompt
+ return ($io.read())