Skip to content

Added new 'jerry_value_strict_equal' API function. #2725

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

Closed

Conversation

LaszloLango
Copy link
Contributor

Added new API function to perform strict equality comparison
between 'jerry_value_t's from C code.

JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]

@LaszloLango LaszloLango added api Related to the public API development Feature implementation labels Jan 22, 2019
@@ -1630,6 +1630,41 @@ jerry_value_is_undefined (const jerry_value_t value)

- [jerry_release_value](#jerry_release_value)


## jerry_value_strict_equal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we gave strict equal check api, then maybe we should also have the simple logic operators also (<, >, ==). However that would be another PR if we decide to implement it.

@LaszloLango LaszloLango force-pushed the strict-equal branch 3 times, most recently from 58e047c to c811850 Compare January 24, 2019 12:35
Added new API function to perform strict equality comparison
between 'jerry_value_t's from C code.

JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
@LaszloLango
Copy link
Contributor Author

I've updated the PR.

/*
* Comparison functions
*/
jerry_value_t jerry_strict_equal (const jerry_value_t lhs, const jerry_value_t rhs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If strict comparison is made part of the public API, shouldn't ecma_op_abstract_equality_compare have its API counterpart, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same was suggested by @galpeter. IMO, It would be nice to add other comparison features to the API as well. I think one new API function/PR is enough. I have two open PRs about this topic, so I do not want to open new similar PRs until these have not been merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I've missed @galpeter 's suggestion. I'm not sure I completely agree with the one function in this PR though. The < and > operators aren't necessarily needed here, but === and == are quite related, so publishing them via API should happen together, IMO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akosthekiss To have other comparison api functions was suggested in my post above, but I had another "idea" which was not written down yet: As we introduce more and more api functions for comparisons, does it make sense to have a single function for each of them or is it possible to have a single api function which can be configured to perform different kind of comparisons?

For example something like this (do not take the naming into account just the concept):

enum jerry_binary_operation {
    JERRY_OP_STRICT_EQUALS, // lhs === rhs
    JERRY_OP_EQUALS, // lhs == rhs
    JERRY_OP_NOT_EQUAL, // lhs != rhs
    JERRY_OP_LESS,  // lhs < rhs
    ...
    JERRY_OP_ADD, // lhs + rhs
};

jerry_value_t
jerry_op (jerry_binary_operation op, jerry_value_t lhs, jerry_value_t rhs);

I'm not sure which approach is better: having api functions for each operation or having a single one. (Maybe this discussion needs its own issue.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@galpeter I like your idea, I will do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the public API development Feature implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants