[WebIDL] Default Values for Arguments

Hi all,

I do not know exactly if this issue/question was already discussed on this
ML, but I didn't find anything in the archive that made it clear.

I'm writing an interface, which has an operation that takes multiple
attributes. However, the last attribute is "quasi-optional" and should be
replaced by a "default value" if the user does not set it in the interface
call.

Here is an example (just to make clear my intention):

interface textbox {
  // while text is mandatory, the color can be set optionally and if not set
to black/0 (default)
  void setText(in DOMString text, in unsigned long long color)
}

If calling
textbox.setText("test");
the color attribute should "per default" be set to black/0, which should (in
my understanding) be specified in the IDL, shouldn't it?

So, the question is if this behavior can/should be formally specified with
the help of WebIDL or if it is not a functional part at all.

Thanks and regards
Steffen Krüssel

PS: The behavior seems to me a bit similar to what [[TreatNullAs]] and
[[TreatUndefinedAs]] respectively (but not restricted to DOMString
arguments).

Received on Friday, 13 November 2009 10:52:32 UTC