Mercurial Hosting > luan
view core/src/luan/init.luan @ 289:ae7ae2755b48
improve Mail;
add String.concat();
git-svn-id: https://luan-java.googlecode.com/svn/trunk@290 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 08 Dec 2014 07:45:40 +0000 |
parents | 9e0d4452e649 |
children | 9a0cc6d9b27b |
line wrap: on
line source
import "luan:Package" import "luan:Basic" import "luan:Table" import "luan:Io" function Package.global(module,fn_name) local function fn(...) return module[fn_name](...) end _G[fn_name] = fn return fn end local require = Package.global(Package,"require") Package.global(Basic,"assert") Package.global(Basic,"assert_boolean") Package.global(Basic,"assert_nil") Package.global(Basic,"assert_number") Package.global(Basic,"assert_string") Package.global(Basic,"assert_table") Package.global(Basic,"assert_integer") local do_file = Package.global(Basic,"do_file") Package.global(Basic,"error") Package.global(Basic,"get_metatable") Package.global(Basic,"ipairs") local load = Package.global(Basic,"load") Package.global(Basic,"load_file") Package.global(Basic,"pairs") Package.global(Basic,"range") Package.global(Basic,"raw_equal") Package.global(Basic,"raw_get") Package.global(Basic,"raw_len") Package.global(Basic,"raw_set") Package.global(Basic,"repr") Package.global(Basic,"set_metatable") Package.global(Basic,"to_boolean") Package.global(Basic,"to_number") local to_string = Package.global(Basic,"to_string") Package.global(Basic,"type") do_file "classpath:luan/version.luan" 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 out.write( '\n' ) else list[#list] = '\n' out.write( Table.unpack(list) ) end end function Basic.print(...) Io.print_to(Io.stdout,...) end local print = Package.global(Basic,"print") local Debug = {} Package.loaded.Debug = Debug _G.Debug = Debug function Debug.print_if_something(...) if Table.pack(...).n > 0 then print(...) end end function Debug.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 local fn = load(line,"stdin",env,true) Debug.print_if_something( fn() ) catch e do print(e) end end end