Sebastian Markbåge (2013-12-25T02:41:48.000Z)
This is an esoteric and ugly use case but I'm not trolling. The default
constructor for a class which extends another is:

constructor(...args){ super(...args); }

Is there any reason it shouldn't return the value from super?

constructor(...args){ return super(...args); }

Basic constructors still have the quirky behavior of ES functions that they
can return any object and don't have to return the instantiated object.
This can be useful if they're used as functions or should return a
placeholder object, or other instance, for compatibility/legacy reasons.
E.g. when you have a custom instantiation process.

class Foo { constructor() { return {}; } }

Currently, this behavior doesn't carry over to subclasses by default:

class Bar extends Foo { }

You'd have to explicitly define a constructor that returns the value from
the super call.

Additionally, since DefineMethod is going to be exposed, does it make sense
to expose ReferencesSuper too?

Otherwise there is no way to detect, at runtime, if a default constructor
function is a top-level constructor (without a super), or a subclass with a
super. One of them can use toMethod but not the other.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131224/6040e82e/attachment.html>
forbes at lindesay.co.uk (2013-12-25T10:49:42.798Z)
This is an esoteric and ugly use case but I'm not trolling. The default
constructor for a class which extends another is:

```js
constructor(...args){ super(...args); }
```

Is there any reason it shouldn't return the value from super?

```js
constructor(...args){ return super(...args); }
```

Basic constructors still have the quirky behavior of ES functions that they
can return any object and don't have to return the instantiated object.
This can be useful if they're used as functions or should return a
placeholder object, or other instance, for compatibility/legacy reasons.
E.g. when you have a custom instantiation process.

```js
class Foo { constructor() { return {}; } }
```

Currently, this behavior doesn't carry over to subclasses by default:

```js
class Bar extends Foo { }
```

You'd have to explicitly define a constructor that returns the value from
the super call.

Additionally, since DefineMethod is going to be exposed, does it make sense
to expose ReferencesSuper too?

Otherwise there is no way to detect, at runtime, if a default constructor
function is a top-level constructor (without a super), or a subclass with a
super. One of them can use toMethod but not the other.