Re: any plans to expand constructor functionality?

On Mon, 02 Jul 2012 02:30:05 +0200, Matt Diamond <mdiamond@jhu.edu> wrote:

> For example, it would be nice to have the ability to instantiate a new
> Oscillator with a specified type... something along the lines of:
>
> var sine = context.createOscillator({ type: Oscillator.SINE });
>
> instead of having to do this:
>
> var sine = context.createOscillator();
> sine.type = sine.SINE;
>
> Of course, this introduces the necessity of exposing the Oscillator class
> to the user, so maybe this isn't the right way to go about it. Still, the
> ability to set parameters on instantiation would make the resulting code
> look a bit cleaner.

The Oscillator interface is already on the global object, since the  
[NoInterfaceObject]  
(http://dev.w3.org/2006/webapi/WebIDL/#NoInterfaceObject) attribute isn't  
(and shouldn't be) used in the Web Audio API spec.

That being said, I have no real opinion about constructor shorthands,  
other than that it should be consistent -- either all properties are  
settable in all constructors, or none are.

-- 
Philip Jägenstedt
Core Developer
Opera Software

Received on Tuesday, 24 July 2012 09:44:34 UTC