diff core/src/luan/modules/Debug.luan @ 298:2ce23c7e2342

remove init.luan git-svn-id: https://luan-java.googlecode.com/svn/trunk@299 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 16 Dec 2014 03:51:56 +0000
parents
children 9fb523472035
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/luan/modules/Debug.luan	Tue Dec 16 03:51:56 2014 +0000
@@ -0,0 +1,25 @@
+import "luan:Table"
+
+
+function print_if_something(...)
+	if Table.pack(...).n > 0 then
+		print(...)
+	end
+end
+
+function debug(prompt)
+	prompt = prompt or "luan_debug> "
+	local function console()
+		return Io.read_console_line(prompt)
+	end
+	local env = {}
+	for line in console do
+		try
+			local fn = load(line,"stdin",env,true)
+			print_if_something( fn() )
+		catch e do
+			print(e)
+		end
+	end
+end
+