Mercurial Hosting > luan
comparison src/luan/lib/init.luan @ 150:f35c50027985
make load() more consistent
git-svn-id: https://luan-java.googlecode.com/svn/trunk@151 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 16 Jun 2014 10:11:48 +0000 |
parents | f99fd64291b3 |
children | d310ebf4d6e7 |
comparison
equal
deleted
inserted
replaced
149:f99fd64291b3 | 150:f35c50027985 |
---|---|
48 if Table.pack(...).n > 0 then | 48 if Table.pack(...).n > 0 then |
49 _G.print(...) | 49 _G.print(...) |
50 end | 50 end |
51 end | 51 end |
52 | 52 |
53 function Table.clone(tbl) | |
54 local new = {} | |
55 for k,v in _G.pairs(tbl) do | |
56 new[k] = v | |
57 end | |
58 return new | |
59 end | |
60 | |
61 function Debug.debug(prompt) | 53 function Debug.debug(prompt) |
62 prompt = prompt or "luan_debug> " | 54 prompt = prompt or "luan_debug> " |
63 local function console() | 55 local function console() |
64 return Io.read_console_line(prompt) | 56 return Io.read_console_line(prompt) |
65 end | 57 end |
66 local env = Table.clone(_G) | 58 local env = {} |
67 for line in console do | 59 for line in console do |
68 try | 60 try |
69 local fn = _G.load(line,"stdin",env,true) | 61 local fn = _G.load(line,"stdin",env,true) |
70 Debug.print_if_something( fn() ) | 62 Debug.print_if_something( fn() ) |
71 catch e do | 63 catch e do |