[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Make type respect __name and add rawtype
- From: Sean Conner <sean@...>
- Date: Thu, 24 Dec 2020 16:00:40 -0500
It was thus said that the Great Andrew Starks once stated:
> On Thu, Dec 24, 2020 at 10:55 AM Spar <email@example.com> wrote:
> > I used *__type *with overridden *type *function for my scripts
> I've used similar magic and as has been pointed out, this has been done by
> many libraries.
> To me, the border between "a good idea" and "a good idea for your code, but
> not for the language" is:
> What's required for interoperability? In this case, is the situation
> improved for the user if the language offers this mechanism for subtyping
I don't quite understand the rational for this. But then again, I'm a fan
of offensive programming  and would prefer for the program to "crash
fast, crash hard" to root out bugs.
For a project, I had need to emulate Lua's file object. So I have this
table that has a read, write, close, seek, setvbuf, flush and seek
functions. Any code that explicitly checks for a type of 'userdata' or an
io.type of "file" will fail, yet if such checks are removed, it should run
This article describes my position.