14:25 | <annevk> | Where is the discussion for Stop Coercing Things? I'm pretty sure most web platform APIs do coerce undefined. |
14:27 | <annevk> | Though perhaps this is mainly about required vs optional arguments in which case I could see where the comparison comes in, but that's a lot narrower. |
14:28 | <annevk> | Also, this should come with some kind of Web IDL story I think. |
16:04 | <bakkot> | annevk: No discussion for it yet, since it hasn't been presented |
16:05 | <bakkot> | and yes it's intended to be mostly about required vs optional, though also I thought web platform guidance was that passing undefined explicitly should be treated exactly like not passing an argument? |
16:05 | <bakkot> | certainly that's how almost all ES functions work |
16:08 | <bakkot> | or to put it a different way: ES already has the principle that passing an explicit undefined should be treated like leaving out an argument, in general, and if we additionally adopt the web-platform behavior of throwing when missing a required argument, that gets us all the way to "stop coercing undefined" |
16:25 | <bakkot> | updated the slides to make the claim about the web platform more correct |
16:41 | <annevk> | bakkot: undefined will be coerced when the argument is required, which is also the case for setters for instances |
16:42 | <annevk> | bakkot: so what you're asserting above is not how required arguments behave when undefined is passed to them |
16:46 | <bakkot> | gotcha |
16:46 | <bakkot> | did not realize web platform made a distinction between explicit undefined and missing argument |
16:46 | <bakkot> | seems bad, hopefully we can change that too going forward |
17:06 | <annevk> | bakkot: it might be an argument you cannot omit, such as that of a setter or when there's multiple required arguments |
17:13 | <bakkot> | annevk: what I mean is, I would generally expect passing an explicit undefined to be treated exactly like omitting the argument; as such if the behavior when omitting an argument which you cannot omit is to throw, that's the behavior I'd expect when passing an explicit undefined |
17:14 | <bakkot> | this is how almost everything in the language itself works, though in the other direction (even omitting nominally "required" arguments doesn't usually throw) |
17:16 | <bakkot> | what I am hoping is that in new APIs in JS and the web platform we can take the intersection of the two behaviors: treat undefined exactly like missing argument, as JS does, and throw when missing a required argument, as the web platform does; as a consequence we would also also throw when passing an explicit undefined |