HE Shi-Jun

Results 543 comments of HE Shi-Jun

@zheeeng It's may much clear `bar` is instance var if we using class1.1 full syntax `this->bar` to differentiate `foo`, but it also throw another question, how programmers see `var bar`...

@dou4cc 这个测试只是用来看看大家对 `class` 级别的 `var` 直觉上的反应。不用想得太深。 当然,如果你对这种用法感到很抵触,可以通过投票表示。 This is only a test to investigate the intuition of the programmers if they see `class`-level `var` usage. Don't think too much. But...

@dou4cc 我不是很明白你的意思。你能不能先明确的说一下你直觉上class-level的var应该是每实例上还是原型上的属性呢?还是其他? > You are against not only prototype but also implementation of existing native methods. 完全不明白你在说什么。也许你用中文直接写会比较容易点? 我再解释一次,这个测试的目的只是为了看大家对于这个代码的直觉。当然我们可以在某项前提下讨论具体的语义(比如call)。

@dou4cc 我知道你选B。我不清楚的是你的其他意思。实例变量跟原型没有关系。

@dou4cc 我大概理解了,你是希望有语法针对原型上的属性?但是原型属性存在一些问题。所以ES6 class就没有加。你可以看我去年演讲的 slide :http://johnhax.net/2017/js-private/slide?qcon#43 。所以不管哪一份草案都不支持原型属性。 至于 let / const ,只是关键字的差别,跟原型没有关系。如果你关心为什么这份草案使用了 var 而不是 let/const,可以看 class1.1 里的 25 号 issue(我不贴链接了,避免产生引用)。

> 我一直好奇你们为什么不提供这样的class风格的写法。 @dou4cc 我并不是TC39的成员。所以这个问题我不能做最权威的回答。不过基本原因就是我前面说的。 另外,我们每个人当然都有自由去相关proposal的讨论里发表意见。我觉得中国程序员去参与标准讨论是一件好事。不过标准提案的讨论的门槛是有点高的,而且又有英语的门槛。如果中国人都弄不懂你的意思,估计老外也看不懂。所以如果对一些问题不是特别清楚,欢迎先在这里提问,我会尽力解释。谢谢。 另外为了保护隐私起见,我把之前你留的联系方式删除了哦。

@yw662 This investigation is try to find what most javascript programmer's intuition on `x` is when they see `class { var x }` without any teaching. The vote result "145:21"...

Yeah, I understand this is a uncommon design in our language. The other case is [numeric literal suffixes](https://github.com/tc39/proposal-extended-numeric-literals#scoping) and a potential case is decorators. I'd like to write a separate...

@ljharb I agree second-class values is not a good idea for JS, but the cases I'm discussing is not second-class values, they are still first-class values, but could be declared/imported...

I understand JS traditionally leave all such responsibility to developers, unfortunately some features would become very impractical if the common cases would take some short and common names. The best...