- From: Cameron McCormack <cam@mcc.id.au>
- Date: Fri, 26 Jun 2009 11:19:04 +1000
- To: Oliver Hunt <oliver@apple.com>
- Cc: Darin Adler <darin@apple.com>, public-webapps@w3.org
Oliver Hunt:
> There's also overloaded functions like (for example)
> CanvasRenderingContext2d.drawImage
> void drawImage(in HTMLImageElement image, in float dx, in float dy,
> [Optional] in float dw, in float dh)
>
> if I do drawImage(image, x, y, foo) is this under-provision for
> drawImage(image,x,y,foo,undefined) or over provision for
> drawImage(image,x,y) or is it an error?
Currently, passing a number of arguments (4) in between the allowed
numbers (3 & 5) gives a TypeError. I’d be inclined to consider these
cases as under-provision.
> Do we need an annotation to say something like
> void drawImage(in HTMLImageElement image, in float dx, in float dy,
> [Optional 2] in float dw, in float dh)
> (or something) that would say the next 2 arguments are optional, but
> both must be provided?
Well, maybe. [Optional] actually means the argument it appears on and
all following, as a group, can be omitted. I think this is a little
confusing, though, so I’m thinking about allowing [Optional] only if it
is the last argument, or if all following arguments are [Optional]
(or [Variadic]). For other cases, like drawImage() here, you can use
explicit overloading:
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);
--
Cameron McCormack ≝ http://mcc.id.au/
Received on Friday, 26 June 2009 01:19:52 UTC