see.lua – Introspecting Lua objects

As via its python equivalent, see.lua takes in an object and prints out a list of its elements as well as metatable methods in readable text.

> require "see"

> s = see(string)
.byte(?)            .char(?)            .dump(?)            .find(?)
.format(?)          .gfind(?)           .gmatch(?)          .gsub(?)
.join(self, table, ...)                 .len(?)
.lower(?)           .match(?)           .rep(?)             .reverse(?)
.sub(?)             .upper(?)    

> see{1,2,3,4,5}
{1, 2, 3, 4, 5}

> see(see)
function(object, query)

> see()
@NIL	nil

> s.join()
@join
function(self, table, ...)

> x = {self = {1,2,3}, four = {1,2,3,5=4}, blargh = ""}
> setmetatable(x, {__call = function() end, __add = function() end, __concat = function() end})
> see(x)
.blargh             .four[4]            .self[3]
Metatable
+                   ()                  ..

You can get it at http://gist.github.com/486964 or the development branch at http://github.com/leegao/see.lua

This entry was posted in Blog, Lua, Programming, Snippets and tagged , , , , , , . Bookmark the permalink.

One Response to see.lua – Introspecting Lua objects

  1. Pingback: See.lua – Documentation | The.Failboat.me

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>