From: Boris Zbarsky [mailto:bzbar...@mit.edu] 

>> TC39 and like-minded people are pushing in the direction of the platform 
>> being mostly a JavaScript library which would indeed give you exactly those 
>> problems...

> Why?

> There is no reason we can't have macros for commonly used ES-style patterns 
> that people can use by reference in specs.  That's supposed to be the purpose 
> of WebIDL.

There's a few aspects of this. Ideally, ES6 will give most of the "macros" 
needed, in the form of class syntax, default arguments, and destructuring 
argument lists. It's not all you need, certainly, but it does obviate a lot of 
WebIDL, the largest remaining piece being type conversions, which Yehuda 
already made a very rough and incomplete start at [1].

Apart from that, the remaining idiomatic patterns will look a lot more like, as 
you say, macros, instead of declarative interface-definition language. For 
example, some kind of macro to indicate "iterate over this incoming iterable 
and/or array-like, and perform the following steps, but throw if not 
`IsObject(putativeIterable)`". Or one to indicate "let returnValue be `new 
this.constructor(...args)`". Or "if `x` is outside the range `y` to `z`, throw 
a `RangeError`".

Now that I write this, I am reminded of the "shorthand phrases" I added for 
promise specs [2]. Hmm.

[1]: http://wycats.github.io/jsidl/jsidl.html
[2]: 
https://github.com/domenic/promises-unwrapping/blob/master/writing-specifications-with-promises.md#shorthand-phrases

Reply via email to