Re: [heycam/webidl] Replace serializers by toJSON and [Default] extended attribute (#323)

tobie commented on this pull request.



> +
+Only [=regular operations=] which have a <dfn>corresponding default operation</dfn> defined below
+may be declared with a [{{Default}}] [=extended attribute=].
+
+
+<h6 id="es-default-tojson">default toJSON operation</h5>
+
+The [=corresponding default operation=] of the “toJSON” operation is the [=default toJSON operation=].
+
+<div algorithm>
+
+    To invoke the <dfn export>default toJSON operation</dfn> of [=interface=] |I|,
+    run the the following steps:
+
+    1.  Let |O| be the <emu-val>this</emu-val> value.
+    1.  Let |result| be [=!=] [=ObjectCreate=]([=%ObjectPrototype%=]).

Yeah. Let/set algo-writing constraints pushed me to write it that way. An implementation obviously shouldn't create the object if it's not needed.

I guess I'll just either:

```
1.  Let |result| be null;
1.  If, … set |result| to …
1.  Otherwise, set |result| to …
```
or:

```
1.  If, … let |result| to …
1.  Otherwise, let |result| to …
```

Which one would you favor?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/323#discussion_r103536749

Received on Tuesday, 28 February 2017 19:46:50 UTC