Mercurial Hosting > luan
diff src/luan/modules/Io.luan @ 1192:e15a41a8b4b2
remove Io.repr
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 26 Feb 2018 14:51:44 -0700 |
parents | 73d754b1889f |
children | 5d0cbd908582 |
line wrap: on
line diff
--- a/src/luan/modules/Io.luan Sun Feb 25 17:17:08 2018 -0700 +++ b/src/luan/modules/Io.luan Mon Feb 26 14:51:44 2018 -0700 @@ -81,61 +81,6 @@ end --- repr - -local function do_repr(out,obj,strict,done) - local tp = type(obj) - if tp == "table" then - if done[obj] == true then - strict and error "circular reference" - out.write "<circular reference>" - return - end - done[obj] = true - out.write( "{" ) - local is_first = true - local in_list = {} - for key, value in ipairs(obj) do - if is_first then is_first = false else out.write ", " end - do_repr(out,value,strict,done) - in_list[key] = true - end - for key, value in pairs(obj) do - if in_list[key] ~= true then - if is_first then is_first = false else out.write ", " end - if type(key) == "string" and matches(key,"^[a-zA-Z_][a-zA-Z_0-9]*$") ~= nil then - out.write( key ) - elseif type(key) == "table" then - out.write( "[<", key, ">]" ) - else - out.write "[" - do_repr(out,key,strict,done) - out.write "]" - end - out.write "=" - do_repr(out,value,strict,done) - end - end - out.write "}" - elseif tp == "string" then - out.write( '"', encode(obj), '"' ) - elseif tp == "nil" or tp == "boolean" or tp == "number" then - out.write( obj ) - else - strict and error("can't repr type '"..tp.."' of "..obj) - out.write( "<", obj, ">" ) - end -end - -function Io.repr(obj,strict) - local string_uri = uri "string:" - local out = string_uri.text_writer() - do_repr(out,obj,strict or false,{}) - out.close() - return string_uri.read_text() -end - - -- debug function Io.debug(prompt)