Giter Site home page Giter Site logo

Comments (8)

bakkot avatar bakkot commented on July 30, 2024 1

See the FAQ for private fields.

In short: of course we started out trying to make it work with the same syntax used in other languages. That turns out not to work.

from proposal-class-fields.

littledan avatar littledan commented on July 30, 2024 1

At the next TC39 meeting, I'll raise this concern again. However, I'm not sure how much more ground there is to cover here--this has already been thoroughly discussed in the private fields issues.

from proposal-class-fields.

bakkot avatar bakkot commented on July 30, 2024 1

@dinoboff See the FAQ for private fields.

from proposal-class-fields.

dinoboff avatar dinoboff commented on July 30, 2024 1

So private x would lead to bad assumption. Can't an other keyword be used instead?

from proposal-class-fields.

bakkot avatar bakkot commented on July 30, 2024 1

We discussed the possibility of an additional keyword for declarations at TC39. Ultimately, we were pretty firm that the declaration should include the #, so that declaration would mirror use and to encourage the mental model that the # is part of the field name. At that point, we felt an additional keyword would just be additional noise for not much benefit.

from proposal-class-fields.

monolithed avatar monolithed commented on July 30, 2024 1

In my opinion the sigil # looks like a syntactic noise and I'd to see something more compatible with TypeScript and other languages.

class Foo {
   private x = 1;

   public y () {
        return this->x;
   }
}


let foo = new Foo();

foo.y(); // 1

Why not to use the arrow -> instead of the dot .?

from proposal-class-fields.

dinoboff avatar dinoboff commented on July 30, 2024

@littledan I understand why access to private fields needs a specific syntax, but that's not true for the declaration. Was the possibility of having a keyword like private x used to declare a private field and using #x only to access it discussed?

from proposal-class-fields.

ljharb avatar ljharb commented on July 30, 2024

@monolithed for your first question, please read the FAQ (this is also answered about 3 comments up)

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.