[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A guide to building Lua modules
- From: Andrew Starks <andrew.starks@...>
- Date: Wed, 16 Apr 2014 15:39:25 -0500
On Wed, Apr 16, 2014 at 2:08 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> 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]
Lua's elegance isn't a part of my point and I agree with your preference.
> 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 ?
Sure. Agreed. There is no disagreement here. If there is a perceived
one, it is that engineering is always a tradeoff. Assuming that we
agree on that, then my postulations are simply *about those
tradeoffs*.
It doesn't necessarily follow that, just because Lua doesn't have
"fancy feature X" that Lua should have it, even if it would make my
life easier. Even for things that I patch out of habit, math being one
of them, I can understand *why* they are that way and am happy to do
what I will to them, in the privacy of my own _ENV.
Lua is whatever it is to you, more so than any other language I can
think of, with the *possible* exception of Ruby. If it replaces
Python, then you're going to want a bunch of crap that someone who is
replacing Tcl/Tk would hate. I always think in the context of this
understanding, not so much in the context of my own use cases.
Whether or not to monkey patch has a whole lot to do with whether
you're the center of your own universe (Warcraft, Love, etc) or not
(rocks, LuaDist).
-Andrew
>
> [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 ;)
>
- References:
- A guide to building Lua modules, Enrique Garcia Cota
- Re: A guide to building Lua modules, Aapo Talvensaari
- Re: A guide to building Lua modules, steve donovan
- Re: A guide to building Lua modules, Tom N Harris
- Re: A guide to building Lua modules, steve donovan
- Re: A guide to building Lua modules, Philipp Janda
- Re: A guide to building Lua modules, steve donovan
- Re: A guide to building Lua modules, Philipp Janda
- Re: A guide to building Lua modules, steve donovan
- Re: A guide to building Lua modules, Philipp Janda
- Re: A guide to building Lua modules, steve donovan
- Re: A guide to building Lua modules, Andrew Starks
- Re: A guide to building Lua modules, steve donovan