-
Notifications
You must be signed in to change notification settings - Fork 113
Is it too late to exchange @ / # usage? #84
Comments
See previous discussion and TC39 minutes about this proposal. |
@littledan Thank you for the links. It seems we still have chance.
Could I say the current continual raised issues by many people in this repo is the signal of revisiting? We are already in stage 3, so no much time left? |
As the person who tried to get them swapped, i don’t think it’s going to happen. For example, one of the reasons brought up not to swap is all the existing documentation out there for both private fields and decorators, in JS and TypeScript. To be frank, i don’t think changing that (let alone all the existing code) is going to be considered worth it due to the aesthetic objections of any number of people. |
@ljharb I understand the situation. I will try to argue three points:
I myself do not have strong opinion in Last year I gave a speech about the private I hope this proposal can land and be success, both JS and TS programmers can use private wisely, in a consistent manner. But in current situation, I worry about it will never happen. |
Coming from a TypeScript environment, I find the choice of both Why not use full words for it? If you don't like |
@kenjiru please read the FAQ which explains why a keyword is not an option. |
@ljharb you got me started, I read the FAQ and the TC39 minute regarding this symbol swap. Now I wish I didn't.. I believe that successful projects like Babel and TypeScript should have an influence on TC39, whether some people like it or not. |
@kenjiru Those projects have a great deal of influence on us. But that doesn't change the fact that TypeScript has a type system and we do not, nor the does it dilute the desire for actual privacy (a desire which the TypeScript team hears quite a bit too). |
Does |
@Jinjiang |
@hax OK well I prefer |
@ljharb Should listen to user opinions |
Was that in favor of the current solution? I thought that both TypeScript and Babel implementing @shaodahong I'm a user and I don't see a problem with |
@shaodahong TC39 always does, but user opinions don’t outweigh actual things that will impact users. |
I'd phrase this slightly differently: In addition to considering programmer points of view about issues that are expressed directly, TC39 also considers potential unintended consequences and subtle interactions that might not be apparent to everyone. |
I find this a quite tenuous. Do you know of any languages where
I think you're mostly referring to the
If you really want consistency with existing use then the main sources of precedent are Java and Python. Java uses the |
Not only C/C++, also some template languages like velocity use In fact I totally agree your points. My point is it's not which is better problem, unfortunately it's which is worse problem. You have to of two evils choose the less. We already know programmers hate |
|
So.. If both @ and # are taken, what's it gonna be for (future not unlikely) protected? The reasons why we can't go with a keyword are still not convincing to me, even after reading the arguments and FAQ multiple times. |
@bschaepper |
@ephys thanks for the links :-) I must say, interessting read. Especially the discussion about making private keyword mandatory, I'd argue, all keywords (public, protected, private) should be mandatory for consistency and clarity. |
Could somebody brief me on why |
@Alhadis because the # is part of the name, the dot is for member access. |
That's what I'm talking about. Using class Secret {
#hidden = true;
hidden = false;
} Would be analogous to: class Secret {
constructor(){
this#hidden = true;
this.hidden = false;
}
} Think of |
@Alhadis there’s a number of reasons why that won’t work, but they’re off topic for this issue. Please file a new one and we can discuss it there (but please first search to see if there’s a relevant existing issue) |
Honestly, I don't feel strongly enough about this issue to pursue suggestions to any great degree. I'll leave the bikeshedding to the experts. ;)
You can tell me at least one, because it seems pretty solidly founded to me. :) I won't derail this thread anymore after that, I promise. ;) |
@Alhadis The alternative proposal Class1.1 is exploring this way which use |
This is better imo. |
@Alhadis One benefit of using |
what about that? class X {
.hidden = 1
test (obj) {
return obj..hidden
}
} |
@d8corp This has the same ASI hazard with shorthand. Also, |
@littledan |
At this point, I'd like to settle on the current meanings of |
While it may be too late, but assume we have the chance to exchange the usage of
@
and#
, aka use@
for private, use#
for decorator, it may help the community to accept this proposal.I know it does not make any difference in semantic, but the feeling of symbol may differ.
JavaScript borrow some notations from CoffeeScript (like arrow functions
=>
), and CoffeeScript use@x
as the shortcut forthis.x
. Though it does not private, but the heavy usage of@xxx
in the class body make it very close to current#priv
lexical scope, give us feel it's only for class inner usage. Also,@x
as instance variable in Ruby language is private.Though it's "subjective", I believe there are less people think
@xxx
is ugly for private field. At least the programmers who have CoffeeScript/Ruby experience can accommodate it soon.On the other hand,
#
is used for comments in many languages, and many languages use comments for annotations, which is close to the decorator feature.#
is also used as the sigil of compile-time directives in many languages, which close to the decorator's goal of making code more declarative. Considerlooks not bad.
I did a small investigation to some TypeScript users who use decorators much. They give me positive feedback about using
#
for decorators. Though it's just a very small sample, I think we could ask the TypeScript community to discuss it.Exchange
@
/#
is not a new idea, it may be discussed before. But see the issue list in the repo, at least half issues shows the bad feeling about#priv
and try to avoid it hopelessly. I can imagine when this proposal reach stage 4, there will be much more negative feedbacks and many attacks which harmful to the whole JavaScript community.I suggest we can reinvestigating the possibility to exchange
@
and#
, thank you.PS. There is an old Chinese idiom 朝三暮四:
Yes, in the history of evolution, we are not far from monkeys/apes 🐒
The text was updated successfully, but these errors were encountered: