Mercurial Hosting > luan
view core/src/luan/modules/Debug.luan @ 326:db37d6aee4db
remove try-catch statement;
add Luan.try() and Luan.pcall();
git-svn-id: https://luan-java.googlecode.com/svn/trunk@327 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 19 Mar 2015 00:01:57 +0000 |
parents | f8ece87df2b1 |
children | 92c3d22745b8 |
line wrap: on
line source
local Luan = require "luan:Luan" local load = Luan.load local try = Luan.try local Io = require "luan:Io" local print = Io.print local Table = require "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 { function() local fn = load(line,"stdin",env,true) print_if_something( fn() ) end; catch = function(e) print(e) end; } end end