Re: APIs that have boolean arguments defaulting to true

On Fri, Nov 15, 2013 at 2:31 PM, Ian Hickson <ian@hixie.ch> wrote:
>> I would probably go even further and say that having string arguments
>> that default to something other than the empty string, or numeric
>> arguments default to something other than 0, or objects that default to
>> something other than null, in cases where empty string/0/null is valid
>> values, seems like a bad idea to me.
>
> That too.
>
> However, lest we decide therefore to make such things invalid in WebIDL...

I don't think we should make it illegal in WebIDL. Like you say, there
are situations when using a non-empty string actually makes for a less
surprising API.

Additionally, there likely will be situations where an empty string
won't be a valid value, but where we can't use enums. Mime types is a
good example of this.

Likewise I could imagine APIs which take numeric values greater than
0. Here too 0 would be an invalid value even if we use a numeric type
in WebIDL.

I could potentially see forbidding boolean values defaulting to true though.

/ Jonas

Received on Friday, 15 November 2013 23:15:27 UTC