Re: [Bug 10336] New: "optional" should be allowed even if subsequent arguments aren't optional

On Tue, Aug 10, 2010 at 1:30 PM, Arthur Barstow <art.barstow@nokia.com>wrote:

> -------- Original Message --------
> Subject:        [Bug 10336] New: "optional" should be allowed even if
> subsequent arguments aren't optional
> Date:   Tue, 10 Aug 2010 00:28:52 +0200
> From:   ext bugzilla@jessica.w3.org <bugzilla@jessica.w3.org>
> To:     public-webapps@w3.org <public-webapps@w3.org>
>
>
>
> http://www.w3.org/Bugs/Public/show_bug.cgi?id=10336
>
>           Summary: "optional" should be allowed even if subsequent
>                    arguments aren't optional
>           Product: WebAppsWG
>           Version: unspecified
>          Platform: PC
>        OS/Version: All
>            Status: NEW
>          Severity: normal
>          Priority: P2
>         Component: WebIDL
>        AssignedTo: cam@mcc.id.au
>        ReportedBy: ian@hixie.ch
>         QAContact: member-webapi-cvs@w3.org
>                CC: mike@w3.org, public-webapps@w3.org
>
>
> It should be possible to say:
>
>  void drawImage(in HTMLImageElement image, in float dx, in float dy, in
> optional float dw, in float dh);
>
> ...so that it means the same as:
>
>  void drawImage(in HTMLImageElement image, in float dx, in float dy);
>  void drawImage(in HTMLImageElement image, in float dx, in float dy, in
> float
> dw, in float dh);
>
> Basically, have "optional" means that if the argument is omitted, all
> subsequent ones must be too, but that if it is included, any subsequent
> arguments up to the next "optional" must be included.
>

This has caused me some confusion in the past.

Why doesn't the WebIDL example provided in this bug also mean I can make the
following call:

void drawImage(in HTMLImageElement image, in float dx, in float dy, in float
dh);

??

Could the optional attribute specified be *independently* optional of
subsequent attributes?

That would be very useful for something like the following:

void find(in SuccessCallback successCB, in optional ErrorCallback errorCB,
in optional ContactFindOptions options);

which would then be equivalent to writing the following long-hand:

void find(in SuccessCallback successCB);
void find(in SuccessCallback successCB, in ErrorCallback errorCB);
void find(in SuccessCallback successCB, in ErrorCallback errorCB, in
ContactFindOptions options);
void find(in SuccessCallback successCB, in ContactFindOptions options);

Any clarification would be helpful.


>
> Currently, "optional" can't be omitted on arguments after the first with
> "optional", so the above isn't possible.
>
>
- Richard

Received on Friday, 13 August 2010 09:33:21 UTC