Rename RequireObjectCoercible in some contexts?

Allen Wirfs-Brock allen at
Fri Nov 27 21:27:10 UTC 2015

> On Nov 26, 2015, at 12:20 AM, Axel Rauschmayer <rauschma at> wrote:
> I realize that this is nit-picky, but the name `RequireObjectCoercible` feels wrong (and not intention-revealing) in the following context (which is not about objects at all):
> 1. Let O be ? RequireObjectCoercible(`this` value).
> 2. Let S be ? ToString(O).
> Something like `RequireActualValue` or `ThrowIfUndefinedOrNull` seems like a better choice here.

RequireObjectCoercible was introduced in ES5 for a few situation (for example, on the MemberExpression to the left of a dot operator) where previously a ToObject had been performed, but where the object conversion was no longer desired. For compatibility reasons, ToObject's throw on undefined/null behavior needed to be preserved and that is what RequireObjectCoercible does. It throws in the exact same cases where ToObject would through. 

`RequireActualValue` seems less descriptive. `ThrowIfUndefinedOrNull` would be ok and more explicit about exactly what it actually does.  However it is somewhat less descriptive of the original intent that it is testing whether the argument is something that is coercible via ToObject.


More information about the es-discuss mailing list