How to refer to the current prototype of a class.
/#!/JoePea
joe at trusktr.io
Sun Aug 7 07:38:51 UTC 2016
> Having such a keyword for convenience may also encourage class designers
to avoid the [Fragile Base Class Problem](
https://www.cs.cmu.edu/~aldrich/papers/selective-open-recursion.pdf).
Maybe not to avoid the fragile base class problem per se, but it would be
easier to express using the current prototype method (on `current`) versus
the leaf-most subclass method (on `this`), and it would ideally be dynamic
so that `current` would depend on where the method is located when it is
called (it could be borrowed from another object).
As for `super`, what's wrong with just using
`Object.getPrototypeOf(Foo.prototype)`?
Well, it's a hard reference, but the fact that `super` is static doesn't
make it any more useful. If `super` (and something like `current`) were
dynamic instead of static, then they would be nice alternatives to using
direct references to a class (f.e. `Foo`) because the methods would be
borrowable, whereas using a reference to a class (like `Foo`) is just as
static as the current `super` is, so`super` really doesn't add anything to
the language except we can replace `Object.getPrototypeOf(Foo.prototype)`
with `super` which is simple shorter to write, but it leaves the method
non-borrowable so it doesn't improve the functionality of the language.
`super` being dynamic would be a functional improvement to the language
rather than a mere syntax sugar for `Object.getPrototypeOf(Foo.prototype)`.
The same would apply to `current`, or whatever it would be named if it were
a thing.
*/#!/*JoePea
On Sat, Aug 6, 2016 at 10:20 PM, /#!/JoePea <joe at trusktr.io> wrote:
>
> On Sun, Jul 31, 2016 at 4:15 AM, Claude Pache <claude.pache at gmail.com>
> wrote:
>
>> What is the issue with just `Foo.prototype`?
>
>
> It means it is subject to renaming (therefore mistakes) when the class
> name needs to be changed. Also, consider how lengthy it is to access a
> getter or setter:
>
> ```js
> Object.getOwnPropertyDescriptor(Foo.prototype,
> 'someSetter').set.call(this, value)
> ```
>
> vs
>
> ```js
> current.someSetter = value
> ```
>
> Having such a keyword for convenience may also encourage class designers
> to avoid the [Fragile Base Class Problem](https://www.cs.cmu.ed
> u/~aldrich/papers/selective-open-recursion.pdf).
>
>
> */#!/*JoePea
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160807/f207c045/attachment.html>
More information about the es-discuss
mailing list