Mercurial Hosting > luan
view core/src/luan/modules/Debug.luan @ 327:0be73ac9103d
handle circular package loading
git-svn-id: https://luan-java.googlecode.com/svn/trunk@328 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 19 Mar 2015 05:36:05 +0000 |
parents | db37d6aee4db |
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