On Sun, Jan 20, 2013 at 10:17 AM, Thijs Schreijer
<notifications@github.com> wrote:
> I'm not in favor of either one, my comment is just to not get stuck in the
> middle. So imo either go all the way (the paranoia option), or leave it as a
> convenience check with limited protection.

I've mostly thought of Penlight as an application library, and perhaps
it's time to talk about sandboxing support for user scripts. We
already have a pretty paranoid pretty.load (although that needs work).

For me, tables with invariant structure are a much more useful form of
defensive programming.  Am thinking of extending pl.strict so that it
gives the standard tables like math, table, etc a metatable to force a
mistyping like math.sine to be an immediate error.  Also, optionally
lock down these tables so that you can exclude monkeypatching, but
alas some libraries do this.

This is also useful for classes, where good practice would be to
define all instance fields in the constructor and thereafter lock the
object, again so that unknown field reads and writes generate errors.

That being said, readonly is a useful function and I will accept this
pull with one little modification; error(...,2) so that the user gets
a better error message pointing to the offending code.

steve d.