thejamesernator at gmail.com (2017-08-28T02:31:33.161Z)
Inline...
On Wed, Aug 23, 2017 at 11:08 AM Vihan Bhargava <contact at vihan.org> wrote:
> The `Proxy` class is great for classes however at the moment, the current
> syntax can be unwieldy:
>
> ```
> class MyClass {
> constructor() {
> return new Proxy(this, {
> get: function(target, name) {
> if (name in target) return target[name];
> // ... do something to determine property
> }
> });
> }
> }
> ```
>
> My proposal is to introduce a more idiomatic syntax for proxies in classes:
>
> ```
> class MyClass {
> constructor () { ... }
> get *(name) {
> // ... do something to determine property
> }
> }
> ```
>
This looks too much like GeneratorMethod syntax:
```
class Foo {
constructor() {}
* gen() {}
}
```
Inline... On Wed, Aug 23, 2017 at 11:08 AM Vihan Bhargava <contact at vihan.org> wrote: > The `Proxy` class is great for classes however at the moment, the current > syntax can be unwieldy: > > ``` > class MyClass { > constructor() { > return new Proxy(this, { > get: function(target, name) { > if (name in target) return target[name]; > // ... do something to determine property > } > }); > } > } > ``` > > My proposal is to introduce a more idiomatic syntax for proxies in classes: > > ``` > class MyClass { > constructor () { ... } > get *(name) { > // ... do something to determine property > } > } > ``` > This looks too much like GeneratorMethod syntax: class Foo { constructor() {} * gen() {} } Rick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170823/d0e16dfc/attachment.html>