[Harmony Proxies] Non-constructable, but callable function proxies

David Bruant bruant at enseirb-matmeca.fr
Sat Mar 12 06:45:28 PST 2011

Le 12/03/2011 11:29, Tom Schuster a écrit :
> Hi,
> the current definition of [[Construct]] doesn't allow to create
> non-constructable objects, but instead just invokes the call handler.
> On easy hackaround would be to check if the constructhandler has a
> [[Construct]] internal method. Then you could create non constructable
> Functions like this:
> Proxy.createFunction({}, function () {}, parseInt);
This sounds very hacky indeed. We're discussing how to make a better
spec, let's not include hacks at this phase :-)

I think I have already asked the question (I cannot find the thread
anymore) and I think I remember the answer was that creating
non-constructable objects wasn't considered as an option. But since I
cannot find the thread, I may have imagined that :-p

Regardless, I think that if there was an intention to be able to create
non-constructable objects with function proxies, there wouldn't be such
an enforcement (throwing if neither callhandler and constructhandler
have a [[Construct]] method).
In order to create non-constructable objects, it could have been decided
to separate the cases when constructhandler is null or undefined (one
creating a non-constrcutable object the other falling back on the
[[construct]] method of callhandler). But this isn't what has been
decided apparently.

If there is a will to not allow non-constructable objects, could a note
be added to the strawman?


More information about the es-discuss mailing list