Mercurial Hosting > luan
diff core/src/luan/modules/Io.luan @ 539:473e456444ff
Remove object-oriented primitive methods for string and binary
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 01 Jun 2015 17:53:55 -0600 |
parents | 92c3d22745b8 |
children | 18504c41b0be |
line wrap: on
line diff
--- a/core/src/luan/modules/Io.luan Mon Jun 01 00:51:44 2015 -0600 +++ b/core/src/luan/modules/Io.luan Mon Jun 01 17:53:55 2015 -0600 @@ -19,11 +19,17 @@ local try = Luan.try local ipairs = Luan.ipairs local pairs = Luan.pairs +local values = Luan.values local Table = require "luan:Table" +local unpack = Table.unpack +local String = require "luan:String" +local encode = String.encode +local matches = String.matches + function M.print_to(out,...) local list = {} - for v in Luan.values(...) do + for v in values(...) do list[#list+1] = to_string(v) list[#list+1] = '\t' end @@ -31,7 +37,7 @@ out.write( '\n' ) else list[#list] = '\n' - out.write( Table.unpack(list) ) + out.write( unpack(list) ) end end @@ -61,7 +67,7 @@ for key, value in pairs(obj) do if in_list[key] ~= true then if is_first then is_first = false else %>, <% end - if type(key) == "string" and key.match "^[a-zA-Z_][a-zA-Z_0-9]*$" ~= nil then + if type(key) == "string" and matches(key,"[a-zA-Z_][a-zA-Z_0-9]*") ~= nil then %><%=key%><% elseif type(key) == "table" then %>[<<%=key%>>]<% @@ -73,7 +79,7 @@ end %>}<% elseif tp == "string" then - %>"<%=obj.encode()%>"<% + %>"<%=encode(obj)%>"<% elseif tp == "nil" or tp == "boolean" or tp == "number" then %><%=obj%><% else @@ -107,7 +113,7 @@ function M.dont_write_when_no(write_fn) return function(...) - for v in Luan.values(...) do + for v in values(...) do if v == NO then return end