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: Add new convention for abstract ops that don't throw #256

Closed
wants to merge 1 commit into from

Conversation

bterlson
Copy link
Member

As discussed in #253. Thoughts on this? I personally find this easier to read.

I've also gone ahead and added ! to a few places where it is needed (mostly ToString invocations). The next biggest class of calls that can't fail are to Type and min/max/friends. Since these can never throw by definition I wonder if it's worth adding ! in these types of cases. I'm leaning toward not on the grounds that Type is a short-hand and min/max/etc. are math functions and so neither actually returns a completion record... Thoughts?

@@ -13851,7 +13848,7 @@
1. Let _nextValue_ be IteratorValue(_next_).
1. If _nextValue_ is an abrupt completion, set _iteratorRecord_.[[done]] to *true*.
1. ReturnIfAbrupt(_nextValue_).
1. Let _status_ be CreateDataProperty(_A_, ToString(_n_), _nextValue_).
1. Let _status_ be CreateDataProperty(_A_, ! ToString(_n_), _nextValue_).
Copy link
Member

Choose a reason for hiding this comment

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

should CreateDataProperty have a ? or a ! in front of it?

@@ -7476,7 +7474,7 @@
1. If _succeeded_ is *false*, return *false*.
1. While _newLen_ < _oldLen_ repeat,
1. Set _oldLen_ to _oldLen_ - 1.
1. Let _deleteSucceeded_ be _A_.[[Delete]](ToString(_oldLen_)).
1. Let _deleteSucceeded_ be _A_.[[Delete]](! ToString(_oldLen_)).
1. Assert: _deleteSucceeded_ is not an abrupt completion.
Copy link
Member

Choose a reason for hiding this comment

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

add prefix on [[Delete]], and remove this line?

@ljharb
Copy link
Member

ljharb commented Dec 16, 2015

k sorry, i'll stop - we should probably check all the Let _status_ and CreateDataProperty usages and that will cover the majority of my comments :-)

@domenic
Copy link
Member

domenic commented Dec 20, 2015

This change is great, and @ljharb's thorough review is great too. We should merge. We can incrementally fix remaining issues later; I kind of expect @anba will have a way of doing so in an automated fashion...

@ljharb
Copy link
Member

ljharb commented Dec 20, 2015

Agreed, I don't think any of my comments should block this change, just cleanups that might be missed later if not caught now :-) this is a huge improvement imo.

@bterlson
Copy link
Member Author

This PR isn't trying to be exhaustive :) Landing this now, please send PRs for all the others as you come across them!

Committed as 166ab2b (rebased, fixed merge conflicts).

@anba
Copy link
Contributor

anba commented Dec 21, 2015

I kind of expect @anba will have a way of doing so in an automated fashion...

Fixing all remaining issues will be a tedious work. I think it's only fair the proponents of the ! prefix get a chance to improve their commit statistics. Here's an incomplete (!) list what needs to be changed. 😝

  • All calls to: IsAccessorDescriptor, IsDataDescriptor, IsGenericDescriptor, ObjectCreate, ToBoolean, IsCallable, IsConstructor, SameValue, SameValueZero, SameValueNonNumber, IsPropertyKey, CreateIterResultObject, CreateBuiltinFunction, CreateRealm, CreateIntrinsics, SetRealmGlobalObject, NewGlobalEnvironment, NewDeclarativeEnvironment, NewObjectEnvironment, NewFunctionEnvironment, NewModuleEnvironment, GetThisEnvironment, GetNewTarget, GetGlobalObject, EnqueueJob, AddRestrictedFunctionProperties, CanonicalNumericIndexString, IsInteger, CreateArrayFromList, CreateListIterator, FunctionAllocate, FunctionInitialize, FunctionCreate, GeneratorFunctionCreate, MakeConstructor, MakeClassConstructor, MakeMethod, SetFunctionName, StringCreate, CreateUnmappedArgumentsObject, CreateMappedArgumentsObject, IntegerIndexedObjectCreate, ModuleNamespaceCreate, ...

Reference type:

  • All calls to: GetBase, GetReferencedName, IsStrictReference, HasPrimitiveBase, IsPropertyReference, IsUnresolvableReference, IsSuperReference, GetThisValue

Declarative Environment Record:

  • All calls to: HasBinding, CreateMutableBinding, CreateImmutableBinding, InitializeBinding, DeleteBinding

Other operations:

  • ToObject in Reference::GetValue and Reference::PutValue
  • CreateDataProperty in FromPropertyDescriptor
  • ToString in "ToString Applied to the Number Type"
  • ToNumber in CanonicalNumericIndexString
  • ArrayCreate in CreateArrayFromList
  • CreateDataProperty in CreateArrayFromList
  • CreateDataProperty in CreateIterResultObject
  • CreateMethodProperty in CreateListIterator
  • DefinePropertyOrThrow in MakeConstructor
  • ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants