Log In  


Hey @zep,

I know this is pretty minor, but I often find myself adding this to my programs so that I can use it in tables of functions/behaviors or other similar circumstances:

function nop() end

It'd be cool, and kind of in keeping with the half-lua/half-asm feel of PICO-8 to have a handy built-in nop() function for such occasions:

function assign_behavior(o,b,f)
  o.behavior[b] = f or nop
end

-- saves me having to do this elsewhere:
if(o.behavior[b]) o.behavior[b]()

I can't be sure, but I bet it might be useful for some tweetcarts too.

Seems like it'd be trivial to add as an efficient built-in C-side function as well. No need to handle args or closures or anything, just spot it and return the empty set immediately.

Anyway, I know it's about as minor a request as a person could possibly make, but still, I figured I'd at least ask. ;)


PS: Honestly, I think even vanilla Lua could use this as an actual built-in, like a pseudo-keyword. In some cases it could be as useful as nil.

11



[Please log in to post a comment]