A change in io metatable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

A change in io metatable

Sean Conner

  I just noticed the following change:

commit 924bed7297d5ea16a78ec07e7acc64afad951aa8
Author: Roberto Ierusalimschy <[hidden email]>
Date:   Mon Jul 1 12:25:00 2019 -0300

    Methods separated from metamethods in 'io'
   
    In the 'io' library, changed the use of the metatable also as its
    own "method table", so that metamethods cannot be accessed as if they
    were methods. (For instance, 'io.stdin.__gc' does not result in
    the finalizer metamethod anymore.)

I'm just curious as to the rational for the change.

  -spc (But you can still get to them via getmetatable())





Reply | Threaded
Open this post in threaded view
|

Re: A change in io metatable

nobody
On 18/07/2019 02.22, Sean Conner wrote:

>
>    I just noticed the following change:
>
> commit 924bed7297d5ea16a78ec07e7acc64afad951aa8
> Author: Roberto Ierusalimschy <[hidden email]>
> Date:   Mon Jul 1 12:25:00 2019 -0300
>
>      Methods separated from metamethods in 'io'
>      
>      In the 'io' library, changed the use of the metatable also as its
>      own "method table", so that metamethods cannot be accessed as if they
>      were methods. (For instance, 'io.stdin.__gc' does not result in
>      the finalizer metamethod anymore.)
>
> I'm just curious as to the rational for the change.
>
>    -spc (But you can still get to them via getmetatable())

See http://lua-users.org/lists/lua-l/2019-06/msg00605.html and followup
by Philipp.

In short: __metatable can(/could) not protect the io metatable, as
io.stdin.__index is(/was) a different path to it.

-- nobody

Reply | Threaded
Open this post in threaded view
|

Re: A change in io metatable

Sean Conner
It was thus said that the Great nobody once stated:

> On 18/07/2019 02.22, Sean Conner wrote:
> >
> >   I just noticed the following change:
> >
> >commit 924bed7297d5ea16a78ec07e7acc64afad951aa8
> >Author: Roberto Ierusalimschy <[hidden email]>
> >Date:   Mon Jul 1 12:25:00 2019 -0300
> >
> >     Methods separated from metamethods in 'io'
> >    
> >     In the 'io' library, changed the use of the metatable also as its
> >     own "method table", so that metamethods cannot be accessed as if they
> >     were methods. (For instance, 'io.stdin.__gc' does not result in
> >     the finalizer metamethod anymore.)
> >
> >I'm just curious as to the rational for the change.
> >
> >   -spc (But you can still get to them via getmetatable())
>
> See http://lua-users.org/lists/lua-l/2019-06/msg00605.html and followup
> by Philipp.
>
> In short: __metatable can(/could) not protect the io metatable, as
> io.stdin.__index is(/was) a different path to it.

  So does that imply that the "best method" for C based modules is now to
emulate the updated io module?

  -spc