This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is just an elaboration of an off-hand toot I made earlier today | |
// concerning a coding pattern I find myself doing whenever possible: passing | |
// and returning owned values instead of borrowing references. | |
// | |
// I find it works well for long-lived values especially since the resulting | |
// composite objects have no lifetime qualifiers, so I don't have to plumb | |
// lifetimes through to all the code that uses them. | |
// Assumption: assume we have a few objects like this: a network connection, a | |
// database, some commands, etc. and we want to make a session type that uses |
I use this data structure all the time. Can someone leave a comment and tell me what it's called?
- insert(k,v): add a new value
- lookup(k): lookup an existing value
- age(): delete old entries (that have not been used since previous call to age())
# Initialize 'old' and 'new' to empty tables
local old, new = {}, {}