Re: [webidl] Stringifiers should allow optional arguments

On 7/11/14, 12:30 PM, Anne van Kesteren wrote:
> On Fri, Jul 11, 2014 at 4:52 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>> In cases when you do "stringifier attribute", sure.  It saves you the
>> trouble of having:
>>
>>    attribute DOMString foo;
>>    DOMString toString();
>>
>> and prose that says that invoking toString() does the same thing as the foo
>> getter.  Which is not very much trouble, imo, compared to what a typical
>> toJSON prose description would need to do.
>
> I guess that would depend on the situation. For both it seems you
> could define an abstract operation and then define the attribute and
> method that have equal behavior in terms of that abstraction.

The toJSON case doesn't usually have an attribute that produces the JSON 
stringification (in fact, I can't think of any cases when that would be 
desirable), so you'd need to create the (fairly complicated!) abstract 
operation just for the toJSON to use.

-Boris

Received on Friday, 11 July 2014 16:35:48 UTC