[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Meta function tables for LUA_FILEHANDLE: why two separate tables?
- From: Sean Conner <sean@...>
- Date: Thu, 17 Nov 2022 19:24:33 -0500
It was thus said that the Great Viacheslav Usov once stated:
> On Wed, Nov 16, 2022 at 8:13 PM Sean Conner <email@example.com> wrote:
> > Perhaps I'm unwise in following "play stupid games, win stupid prizes"
> > (i.e. trusting a programmer to not nil out __gc metamethods) but I really
> > have to wonder how much of an issue this really is. Do you have actual code
> > this breaks? Or is this more of a "hypothetical, someone might, possibly,
> > break some code I wrote" type of issue? (and am I asking for trouble for
> > asking for an actual example? Am I stupid for not thinking this is an
> > issue? Should every Lua module written in C do the same as Lua's io
> > library?)
> I found it surprising, in the old discussion, and, apparently, in the
> ensuing discussion, how something obviously wrong was being declared
> no big deal or even desirable.
The difference is of opinion. I do not think this is obviously wrong, nor
have I been convinced that it's even wrong. I think that monkeypatching 
is wrong, and I will try to disuade people from doing it ("play stupid
games" and all that), but I do admit that it is sometimes desirable to do
 and won't try to make it impossible.
 Changing the behavior of a language or system at runtime. It's
quite popular in Ruby for instance.
 I've done it. I've added a "_tofd" function  to Lua's metatable
for files to obtain the underlying Unix file descriptor to relieve
the programmer from having to do this each time they want to add a
file to my select() wrapper . I have the same method in my
network wrapper .