CARVIEW |
Select Language
HTTP/2 200
date: Wed, 08 Oct 2025 03:09:23 GMT
content-type: text/html
content-encoding: gzip
last-modified: Thu, 13 Jul 2023 17:37:24 GMT
cache-control: max-age=2592000, public
expires: Thu, 06 Nov 2025 04:07:42 GMT
vary: Accept-Encoding
access-control-allow-origin: *
x-request-id: 98aa887c2ccb38e5
strict-transport-security: max-age=15552015; preload
x-frame-options: deny
x-xss-protection: 1; mode=block
cf-cache-status: HIT
set-cookie: __cf_bm=JaDBymv1eEaLeHZt6yvgIRhJQxK337dDWA0Y493wJto-1759892963-1.0.1.1-cZfVIhsP3mCOJx32Vih.zFxSyVpnAREEU43d9hZpYP3tp3GYQq7C6_syah3Qv4aUprxGA.tm._oFqufeM9YNMbfMXhUC9wyQhU.4YKA7vBM; path=/; expires=Wed, 08-Oct-25 03:39:23 GMT; domain=.w3.org; HttpOnly; Secure; SameSite=None
server: cloudflare
cf-ray: 98b2706c9f6cc151-BLR
alt-svc: h3=":443"; ma=86400
APIs that have boolean arguments defaulting to true from Boris Zbarsky on 2013-11-11 (public-script-coord@w3.org from October to December 2013)
APIs that have boolean arguments defaulting to true
- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Mon, 11 Nov 2013 14:37:55 -0500
- To: "public-script-coord@w3.org" <public-script-coord@w3.org>
- Message-ID: <52813213.6050700@mit.edu>
Dear all, One take-away I have from the current attempts to make undefined be treated as missing is that we should avoid creating APIs that have arguments of the form "optional boolean arg = true". The reason for that is that I think the behavior of such an argument when combined with the conventions for undefined is very surprising. Consider a function declared as: void foo(optional boolean arg = foo); and these two patterns of calling it: if (myValue) { foo(true); } else { foo(false); } and foo(myValue); These two patterns have different behavior, which seems very unintuitive to me and to everyone else I've pointed this out to... This does mean that we can't have "foo()" with no arguments default to true, so we should probably design APIs such that "false" gives the sane default behavior if there's an optional boolean argument at all. Thoughts? -Boris
Received on Monday, 11 November 2013 19:38:29 UTC