Determine if a value is Callable/Constructible

Caitlin Potter caitpotter88 at gmail.com
Mon Mar 30 16:24:39 UTC 2015


>Unfortunately, we can't use a magic method name.  Just to throw out a couple of other ideas though: 

>Contextual keyword after constructor:
>
>    class C {
>      constructor() { /* new me */ }
>      constructor call() { /* call me */ }
>    }

This one looks like the most readable — I would make a slight adjustment:

    class C {
      constructor() { /* new me *. }
      call constructor() { /* call me */ }
    }

(just for the purpose of readability)

I think it might be hard to mix this up with computed property names, so `call [‘constructor’]()` might be a no-go? same with `[‘constructor’] call()` tbh

> On Mar 30, 2015, at 12:20 PM, Kevin Smith <zenparsing at gmail.com> wrote:
> 
> I like the idea of a special syntactic form a lot. One of the nice things about `constructor` is that it's easy to explain "you [[Construct]] with the constructor". We can't use `call` similarly any more, but I totally agree something like it would be pretty nice.
> 
> Unfortunately, we can't use a magic method name.  Just to throw out a couple of other ideas though: 
> 
> Parens sans method name:
> 
>     class C {
>       constructor() { /* new me */ }
>       () { /* call me */ }
>     }
> 
> Contextual keyword after constructor:
> 
>     class C {
>       constructor() { /* new me */ }
>       constructor call() { /* call me */ }
>     }
> 
> With a "dot" instead:
> 
>     class C {
>       constructor() { /* new me */ }
>       constructor.call() { /* call me */ }
>     }
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150330/5bc0bb0b/attachment-0001.html>


More information about the es-discuss mailing list