Giter Club home page Giter Club logo

Comments (1)

rurban avatar rurban commented on May 18, 2024

Not a bug. ctor vs object.

Try this:

$ bin/potion -Dt -e'Object()
Object
Object()
Object()!=Object'
-- run-time --
[ 1] self     1     ; Lobby
[ 2] loadk    0 0   ; Object
[ 3] msg      0 1   ; Object
[ 4] call     0 1   ; <Object 7ffca42d26d8>
[ 5] self     1     ; Lobby
[ 6] loadk    0 0   ; Object
[ 7] bind     0 1   ; function Object()
[ 8] loadpn   2 0   ; nil
[ 9] call     0 2   ; Object
[10] self     1     ; Lobby
[11] loadk    0 0   ; Object
[12] msg      0 1   ; Object
[13] call     0 1   ; <Object 7ffca42d2860>
[14] self     1     ; Lobby
[15] loadk    0 0   ; Object
[16] msg      0 1   ; Object
[17] call     0 1   ; <Object 7ffca42d2948>
[18] self     2     ; Lobby
[19] loadk    1 0   ; Object
[20] bind     1 2   ; function Object()
[21] loadpn   3 0   ; nil
[22] call     1 3   ; Object
[23] neq      0 1   ; <Object 7ffca42d2948>!=Object ; true
[24] return   0     ; true

With -Dvt even more.

Object() creates a new Object instance, it is the ctor ("constructor").
That's the first VTABLE path in OP_CALL in the vm, calling potion_object_new(), and then falling thru to the 2nd closure path.

Object returns the current Object.
That's running only the second CLOSURE path in OP_CALL in the vm, just calling the
closure without creating a new object.

from potion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.