lua-users home
lua-l archive

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


On Wed, Apr 16, 2014 at 5:19 PM, Andrew Starks <andrew.starks@trms.com> wrote:
> I monkeypatch all of the time, but:>
> I create an environment using _ENV>
> I copy the library into a new table and make my additions and changes there.

That's patching, sure, but does it involve monkeys?  I doubt it, since
the essence of a monkey patch is to go straight for a shared resource
and modify it.  You've made a copy, so it's no longer a global
problem.

> thing", especially in the string library, is because Lua shares
> elements of a typed language that, for example, Ruby doesn't. I simply
> can't make a string-like table and expect it to work fine as a string,

It's true that Lua is not perfectly elegant, but there is (probably)
going to be a price to pay for elegance[1].  I'd rather keep that VM
lean & mean than play entertaining games with pseudo-strings....[2]

And yes ... type() and __type.  Which seems a harmless modification if
it is identical in the absence of a __type metafield, but why do
people feel a need to modify the global?  Can it not be done at the
top of modules that use it, so that other people can say ... aha, type
modified ?

[1] old joke about Lisp programmers: they know the value of everything
and the cost of nothing.  (sounds like the kind of thing Alan Kay
said)
[2] basically because I distrust code that is too implicit, too
generic - which is probably a reaction against my earlier excesses of
course ;)