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

Editorial: refactor common behaviour of SetFunctionName #1384

Closed
wants to merge 1 commit into from

Conversation

devsnek
Copy link
Member

@devsnek devsnek commented Dec 28, 2018

No description provided.

1. Assert: Type(_name_) is either Symbol or String.
1. Assert: If _prefix_ is present, then Type(_prefix_) is String.
1. If ! HasOwnProperty(_F_, `"name"`) is *true*, return.
Copy link
Member

Choose a reason for hiding this comment

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

I’m not sure it’s as clear to have an operation named “set function name” not always set the function name, although i see how this DRYs up the steps. What do you think?

Copy link
Collaborator

@jmdyck jmdyck Dec 28, 2018

Choose a reason for hiding this comment

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

You could change the name to something like EnsureFunctionName (i.e., it ensures that the function has a name, setting it only if necessary).

Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering the same thing as @ljharb. I like the general idea of cleaning things up with refactoring, but for specs we should prioritize clarity.

1. Assert: Type(_name_) is either Symbol or String.
1. Assert: If _prefix_ is present, then Type(_prefix_) is String.
1. If ! HasOwnProperty(_F_, `"name"`) is *true*, return.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where the replaced code has a call to HasOwnProperty, that call is always preceded by '?'. I don't think you're justified in changing that to '!' here. Moreover, in those cases, the resulting call to SetFunctionName should be preceded by '?'.

@devsnek devsnek force-pushed the refactor/setfunctionname branch from cca351f to cda05c6 Compare December 28, 2018 23:00
@TimothyGu
Copy link
Member

There exists usage of the SetFunctionName abstract operation in other non-algorithmic parts of the spec, such as in the Web IDL specification. If this pull request were to land, modifications to that specification to use the new EnsureFunctionName would be nice.

Alternatively, we could provide a compatibility SetFunctionName abstract operation in ECMA-262 still.

@anba
Copy link
Contributor

anba commented Jan 2, 2019

I wonder if it makes sense to delay merging this PR after we get a decision on #1372, because if this PR is first merged and at a later point #1372, #1372 will revert the name change from "EnsureFunctionName" back to "SetFunctionName" and also remove the HasOwnProperty check in SetFunctionName/EnsureFunctionName.

@devsnek
Copy link
Member Author

devsnek commented Jan 7, 2019

I think #1373 does what I was looking to do with this. Any reason anyone sees to keep this open?

@devsnek devsnek closed this Sep 5, 2019
@devsnek devsnek deleted the refactor/setfunctionname branch September 5, 2019 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants