W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2009

[WebIDL] Default Values for Arguments

From: Steffen Krüssel <steffen.kruessel@googlemail.com>
Date: Fri, 13 Nov 2009 11:03:35 +0100
Message-ID: <e29a0b640911130203u3b3e9fgbe4c8abb988f769f@mail.gmail.com>
To: public-webapps@w3.org
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:35 GMT