-
Notifications
You must be signed in to change notification settings - Fork 41
Resolve inconsistencies between null and undefined #25
Comments
The majority of the JS community treats However, argument/destructuring defaults, in particular, only apply to So, I think weakrefs could legitimately choose either one. tc39/proposal-nullish-coalescing#20 is a relevant issue for nullish coalescing, which will have to make and defend the same choice (my strong hope is that it treats the two identically). |
The open questions section discusses this question some. The fallback answer is "undefined", which was concluded after the first draft. The spec text and implementation in the current proposal consistently say "unefined" for the target and "null" for the holdings, but I think that's a mistake and it should just be "undefined". The rationale is that this is about references, and "undefined" is equivalent to "you don't have a reference (e.g., if you provide fewer arguments to a functions than expected). So GC returns the reference to an "uninitialized state". |
Can you point me at parts that imply |
Proposed Solutions says
Basic Usage says assert(wr.get() === null); |
The current proposal uses undefined, not null, for the WeakRef deref method when the object has already been collected. This matches my intuition of undefined standing for missing values. I am not aware of any inconsistencies. Would it make sense to close this issue? |
Yeah, it looks like the spec is all cleaned up now. |
Some parts of the spec say or imply that
'get
/deref
on a weakref whose target is collected returnsnull
. Other parts say or implyvoid 0
, i.e.,undefined
.There may also be inconsistencies with the holdings, but I did not look as carefully. In any case, we need to look and resolve any such inconsistencies.
I can't see any way to observe whether an executor is null or undefined, but we should be sure we're consistent here anyway.
Has anyone written down any widely accepted criteria for choosing between
null
andundefined
?The text was updated successfully, but these errors were encountered: