Skip to content

Instantly share code, notes, and snippets.

View gvvaughan's full-sized avatar

Gary V. Vaughan gvvaughan

View GitHub Profile
@terminaldweller
terminaldweller / cstruct2luatable2.md
Last active August 14, 2020 21:04
C Struct to Lua Table

C Struct to Lua table

Overview

For this tutorial we'll change a C struct into a Lua table. The structure we'll be using won't be the simplest structure you'll come across in the wild so hopefully the tutorial will do a little more than just cover the basics.
We'll add the structures as userdata and not as lightuserdata. Because of that, we won't have to manage the memory ourselves, instead we will let Lua's GC handle it for us.
Disclaimer:

  • This turotial is not supposed to be a full dive into lua tables, metatables and their implementation or behavior. The tutorial is meant as an entry point into implementing custom Lua tables.

Yet Another One?

There are already a couple of tutorials on this, yes, but the ones I managed to find were all targeting older versions of lua and as the Lua devs have clearly stated, different Lua version are really different. The other reason I wrote this is I needed a structures that had structure members themselves and I couldn't find a tutorial for t

@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active May 19, 2024 19:25
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@stevedonovan
stevedonovan / install.lua
Created September 28, 2013 13:37
A simple Lua install script for Lua modules, extensions and scripts. Tested on Windows and Linux.
#!/usr/bin/env lua
--[[ -- installing LDoc
function install()
-- requires('pl','Penlight')
-- install_script 'ldoc'
end
--]]
-- --[[