Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce 'ecma_is_value_nullish' #5170

Open
LaszloLango opened this issue Nov 19, 2024 · 1 comment
Open

Introduce 'ecma_is_value_nullish' #5170

LaszloLango opened this issue Nov 19, 2024 · 1 comment
Labels
ecma core Related to core ECMA functionality enhancement An improvement minor

Comments

@LaszloLango
Copy link
Contributor

ecma_is_value_null and ecma_is_value_undefined is used together in multiple places in the source code. It would nice to have a new ecma_is_value_nullish function to make the code simpler and more readable. e.g:

extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_nullish (ecma_value_t value) /**< ecma value */
{
  return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_NULL) || ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_UNDEFINED);
} /* ecma_is_value_null */
@LaszloLango LaszloLango added enhancement An improvement ecma core Related to core ECMA functionality labels Nov 19, 2024
@ossy-szeged
Copy link
Contributor

ossy-szeged commented Nov 27, 2024

Nullish naming can be a little bit confusing, because ECMAScript specification doesn't use this term. There are many places in the spec, where an expression should be checked if it is undefined or null. Maybe the ecma_is_value_null_or_undefined(...) would fit better to the ES spec terms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecma core Related to core ECMA functionality enhancement An improvement minor
Projects
None yet
Development

No branches or pull requests

2 participants