From 364f3c894b34e20c72f3d7ff273d2519affd9963 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 23 Jan 2019 15:43:19 -0800 Subject: 'say' is now it's own action, rather than a 'print' clone, which lets it handle multiple arguments better. --- lib/core/io.nom | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/core/io.nom b/lib/core/io.nom index 90cfbd4..df52c92 100644 --- a/lib/core/io.nom +++ b/lib/core/io.nom @@ -3,27 +3,20 @@ This file contains basic input/output code use "core/metaprogramming" +use "core/operators" +use "core/control_flow" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ external: - (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 (*extra arguments*)) means: + for $ in 1 to (select "#" (*extra arguments*)): + $arg = (select $ (*extra arguments*)) + $io.write ($arg as text) + $io.write "\n" + $io.flush() - (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 - ") + (say $message inline) means ($io.write $message) (ask $prompt) means: $io.write $prompt -- cgit v1.2.3