Tag Archives: function

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(?)

Posted in Blog, Lua, Programming, Snippets | Tagged , , , , , , | 1 Comment

Lua – Get number of parameters in a function

The following snippet defines a function num_args(func) that returns the number of parameters within a function as a string:

num_args(function(a,b,c) end) --> 3

It also works with functions that have variable arguments:

num_args(function(a,...)

Posted in Blog, Lua, Programming, Snippets | Tagged , , , , | Leave a comment

Python – Abstract Function class

Python is great. It’s dynamic, it’s flexible, and best of all, for almost all major datatypes, there’s an associated abstract class from which you can over-ride and build your own object out of.

Of course, Python doesn’t treat functions in…

Posted in Programming, Python, Snippets | Tagged , , , , , , , , , , , , | Leave a comment