lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Sir Pogsalot once stated:
> I am saying that it is out of my control, as it is done by code I did not
> write.  So the metatable check works but the subsequent rawlen() fails.

  That's what I'm not understanding---the call to lua_rawlen().  To me, it
sounds like a defensive programmer going overboard.  Personally, I don't
believe in defensive programming as it hides bugs [1].  Trust the
programmer; do NOT trust the outside world though.

>  luaL_checkudata() does not prevent a user from causing a segfault if they
> match up your mt with a very small userdata...

  It's not the user that causes that, it's the programmer.

  -spc (Fail fast)

[1]	Writing Solid Code_ by Steve Maguire goes into this in depth.  It
	was one of only two books I've read over the past 25 years that
	fundamentally changed how I write code.