view core/src/luan/modules/Debug.luan @ 321:7f7708e8fdd4

remove import statement git-svn-id: https://luan-java.googlecode.com/svn/trunk@322 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 08 Feb 2015 07:26:20 +0000
parents 9fb523472035
children f8ece87df2b1
line wrap: on
line source

local Table = require "luan:Table"
local Io = require "luan:Io"
local print = Io.print


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