lua-users home
lua-l archive

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


On 16 April 2014 14:46, Andrew Starks <andrew.starks@trms.com> wrote:
> On Wed, Apr 16, 2014 at 12:15 PM, Hisham <h@hisham.hm> wrote:
>> I know I'll be burned at the stake but here it goes:
>>
>> Monkey Patching is Never Really Needed. People do it just because they can,
>
> ... says the guy who demonstrated `"Hello, %s." % {"world"}`

Did I? I remember the one with making << behave like in C++, but that
was of course a joke. :)

> Sooooo... monkey patching is what? Using libraries of the same name
> but with different behavior? So I'm not monkey patching if I copy /
> patch all of the methods from `math` into my own `mathx` library and
> add whatever behavior I wish.
>
> This is all just a cautionary warning to use unique names for your own
> libraries, even when your intent is to extend behavior, not change
> it... right?

Yeah, I guess it's another way of saying "don't mess with other
people's namespaces".

> I think that this is one of those lessons that I'm going to need to
> learn through some late night of debugging caused by the subtle
> problems created by bad behavior that I'm not currently capable of
> capturing.
>
> I like pretending that `math` knows how to deal with my real
> fractions. When the day comes that it all blows up on my, global
> search and replace will once again prove to be a powerful ally.

When tweaks are easily searchable, it's easy; when it's things like
checking every possible t[x], it gets hairy...

-- Hisham