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

Fwd: [WebIDL] Default Values for Arguments

From: Steffen Krüssel <steffen.kruessel@googlemail.com>
Date: Fri, 13 Nov 2009 13:19:08 +0100
Message-ID: <e29a0b640911130419y415f757bs8562e7fb7ee24cfb@mail.gmail.com>
To: public-script-coord@w3.org
Wrong ML. This should now be the right one (thanks to Arthur Barstow), sorry
for that.
Steffen Krüssel

---------- Forwarded message ----------
From: Steffen Krüssel <steffen.kruessel@googlemail.com>
Date: 2009/11/13
Subject: Re: [WebIDL] Default Values for Arguments
To: Simon Pieters <simonp@opera.com>
Cc: public-webapps@w3.org

2009/11/13 Simon Pieters <simonp@opera.com>

On Fri, 13 Nov 2009 11:03:35 +0100, Steffen Krüssel <
> steffen.kruessel@googlemail.com> wrote:
>  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.
> I think you want something like:
>   interface textbox {
>     void setText(in DOMString text, in optional unsigned long long color);
> // why long long?

This was just an example, could have been everything except for DOMString.
I don't think that the "optional" attribute is sufficient as this does not
(formally) specifies what is being implicitly done in that case (i.e. using
a default value). "Optional" only says that the given attribute is not
relevant for the further process, but in the example it is relevant, as the
attribute always influences the text appearance. How can/should I tell the
developer what he/she can expect?

>   When the color argument is omitted, the default value of black/0 must
>   be used.
>  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).
> --
> Simon Pieters
> Opera Software
Received on Friday, 13 November 2009 12:19:58 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:01 UTC