Mercurial Hosting > luan
diff src/luan/lib/init.luan @ 139:3b384dc5ca91
replace WebShell.java with web_shell.luan
git-svn-id: https://luan-java.googlecode.com/svn/trunk@140 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 13 Jun 2014 12:26:44 +0000 |
parents | 98aba462c422 |
children | c2ee8a717b73 |
line wrap: on
line diff
--- a/src/luan/lib/init.luan Thu Jun 12 08:20:48 2014 +0000 +++ b/src/luan/lib/init.luan Fri Jun 13 12:26:44 2014 +0000 @@ -1,26 +1,33 @@ --Io.stdout.write "this is init.luan\n" -local function print(...) +function Io.print_to(out,...) local list = {} for _,v in Basic.values(...) do list[#list+1] = to_string(v) list[#list+1] = '\t' end if #list == 0 then - Io.stdout.write( '\n' ) + out.write( '\n' ) else list[#list] = '\n' - Io.stdout.write( Table.unpack(list) ) + out.write( Table.unpack(list) ) end end -_G.print = print - +function _G.print(...) + Io.print_to(Io.stdout,...) +end local Debug = {} Package.loaded.Debug = Debug _G.Debug = Debug +function Debug.print_if_something(...) + if Table.pack(...).n > 0 then + _G.print(...) + end +end + function Debug.debug(prompt) prompt = prompt or "luan_debug> " local function console() @@ -29,10 +36,7 @@ for line in console do try local fn = load(line,"stdin",true,true) - local result = Table.pack( fn() ) - if result.n > 0 then - print( Table.unpack(result,1,result.n) ) - end + Debug.print_if_something( fn() ) catch e do print(e) end