Monthly Archives: April 2010

Lua Exception Handling

Wouldn’t it be awsome if you could do something like

dofile "try"

try{
	function()
		a = a/a
	end
}.except(Exceptions.ValueError){
	function(_, exceptions, detail)
		print(detail)
	end
}

And get

lua:5: attempt to perform arithmetic on

Posted in Blog, Lua, Programming, Snippets | Tagged , , , , | 2 Comments

Linked Lists via ctypes in Python

from ctypes import *

class linknode(Structure):
    pass
linknode._fields_ = [
                ("nextNode", POINTER(linknode)),
                ("intData", c_int),
                ]
class linked_list():
    head_node = None
    def add(self, int_data):
        node_to_add = linknode(intData = c_int(int_data))
        if (self.head_node == None):
            self.head_node = node_to_add
        else:
            traverse_node

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