Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
297:899253043270 | 298:2ce23c7e2342 |
---|---|
1 import "luan:Table" | |
2 | |
3 | |
4 function print_if_something(...) | |
5 if Table.pack(...).n > 0 then | |
6 print(...) | |
7 end | |
8 end | |
9 | |
10 function debug(prompt) | |
11 prompt = prompt or "luan_debug> " | |
12 local function console() | |
13 return Io.read_console_line(prompt) | |
14 end | |
15 local env = {} | |
16 for line in console do | |
17 try | |
18 local fn = load(line,"stdin",env,true) | |
19 print_if_something( fn() ) | |
20 catch e do | |
21 print(e) | |
22 end | |
23 end | |
24 end | |
25 |