[[Call]] vs. [[Construct]] using symbols

Herby Vojčík herby at mailbox.sk
Sun Oct 7 02:10:17 PDT 2012



Brendan Eich wrote:
> Before we add more unstratified traps, I'd like Tom and Mark to comment.
> They've thought a lot about invariants to preserve even with proxies in
> the picture, and also for non-proxies. And they have a use-case to test
> against: SES.
>
> Herby Vojčík wrote:
>> But this has some quirks to solve, like typeof must be "function" for
>> every object having @call, but what about object having only @construct?
>
> If we do this, then let's hope testing (@construct in obj) isn't too
> bad. I suspect it won't be all that common.

These were just "extended" thoughs.

The main thing I wanted to propose / get feedback is the simple [[Call]] 
vs [[Construct]] separation for max-min classes using const systemwide 
symbols @call and @construct, since we already have the precedent of 
@iterator (the rest were thoughts about possibility of generalizing it).

In other words, no real traps at all. Just convenient names @construct 
and/or @call used instead of (also convenient) name 'constructor'.

Like in:
	class Foo {
		@construct(x, y) {
			// initialize the instance
		}
		@call(obj) {
			// convert obj into Foo
		}
		// the rest of the methods
	}
with the result of Foo constuctor function implemented so it can 
distingiush between [[Call]] and [[Construct]] context and doing the 
respective code.

Herby

> /be


More information about the es-discuss mailing list