Giter Site home page Giter Site logo

Factory class about proposal-class-fields HOT 5 CLOSED

tc39 avatar tc39 commented on July 30, 2024
Factory class

from proposal-class-fields.

Comments (5)

bakkot avatar bakkot commented on July 30, 2024

Among other things, factory functions cannot readily create instances which can interact with each other's private fields, not build brand checking methods like Array.isArray.

from proposal-class-fields.

kofifus avatar kofifus commented on July 30, 2024

Hey bakkot, thanks for replying.

factory functions cannot readily create instances which can interact with each other's private fields

I am confused as to why this is a desirable thing.. Can you please refer me to the part of the suggested standard that talks about this ? is this something like C++ friend mechanism ?

not build brand checking methods like Array.isArray

Isn't that what instanceOf is for ? (which can easily be supported as is in the above mentioned solution)

from proposal-class-fields.

bakkot avatar bakkot commented on July 30, 2024

No, not like friend. See the faq. This is how it works in almost all languages with some notion of "private fields", and is useful for making methods like "equals".

instanceof is not a reliable brand check, since prototypes can be changed.

from proposal-class-fields.

kofifus avatar kofifus commented on July 30, 2024

Ah I see,

brand check can pretty easily be added to factory. However such an equals method cannot.

from proposal-class-fields.

littledan avatar littledan commented on July 30, 2024

Some more advantages: More straightforward for a JIT to optimize, and more ergonomic.

from proposal-class-fields.

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.