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

Properly format conditionals #657

Merged
merged 4 commits into from
May 20, 2019
Merged

Conversation

Manishearth
Copy link
Contributor

@Manishearth Manishearth commented May 17, 2019

Fixes #647

Contains no behavior changes, only formatting. In some cases we had "If foo do ... and abort these steps. Else do ...", I just simplified these cases by removing the else.

Rendered

cc @ddorwin

r? @toji

Copy link
Contributor

@ddorwin ddorwin left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good, though I didn't review all the details.

index.bs Outdated
<dl class="switch">
<dt> If the [=XR/XR device=] is <code>null</code>
<dd> [=Reject=] |promise| with <code>null</code>.
<dt> Else if the [=XR/XR device=]'s [=list of supported modes=] does not [=list/contain=] |mode|
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the intro, I think this can just be "If..."

<dd> [=Reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}}.
<dt> Else if |immersive| is <code>true</code> and the algorithm is not [=triggered by user activation=]
<dd> [=Reject=] |promise| with a "{{SecurityError}}" {{DOMException}}.
</dl>
Copy link
Contributor

Choose a reason for hiding this comment

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

There should probably be an Otherwise given the intro. It can just say "Continue to the next step." or something like that.

index.bs Outdated
<dl class="switch">
<dt> If |immersive| is <code>true</code>
<dd> Set the [=active immersive session=] to |session|, and set [=pending immersive session=] to <code>false</code>.
<dt> Else
Copy link
Contributor

Choose a reason for hiding this comment

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

Line 244 uses Otherwise, which is also used in at least some other specs. Most importantly, this spec should be consistent.

@Manishearth
Copy link
Contributor Author

Addressed

Copy link
Member

@toji toji left a comment

Choose a reason for hiding this comment

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

Looks good. I'm a little wary of over-applying this particular pattern and accidentally making the spec harder to read as a result, but after reading through your changes carefully I think these are all appropriate cases for the switch statement. I spotted one minor error, but once that's fixed I'm happy to merge.

index.bs Outdated
<dd> Let |referenceSpace| be a new {{XRBoundedReferenceSpace}}.
<dt> Else
<dd> Let |referenceSpace| be a new {{XRReferenceSpace}}.
</dl>
1. If |type| is {{bounded-floor}}, let |referenceSpace| be a new {{XRBoundedReferenceSpace}}.
1. Else let |referenceSpace| be a new {{XRReferenceSpace}}.
Copy link
Member

Choose a reason for hiding this comment

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

This line and the one above it should be removed now, since they're covered in the new switch statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

@ddorwin ddorwin left a comment

Choose a reason for hiding this comment

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

Thanks. One comment about consistency.

index.bs Outdated
<dl class="switch">
<dt> If |type| is {{bounded-floor}}
<dd> Let |referenceSpace| be a new {{XRBoundedReferenceSpace}}.
<dt> Else
Copy link
Contributor

Choose a reason for hiding this comment

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

There are six instances of Else. Should those be Otherwise for consistency?

Copy link
Member

@toji toji May 20, 2019

Choose a reason for hiding this comment

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

Honestly I think Else is fine in these cases, especially if it's just a simple if/else statement. Where I would expect Otherwise to apply is mostly at the end of a switch with several branches. (Functioning as default in a C++ switch, essentially)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@toji toji merged commit ffc363c into immersive-web:master May 20, 2019
@Manishearth Manishearth deleted the conditionals branch May 20, 2019 20:25
@AdaRoseCannon AdaRoseCannon added the ed:spec Include in newsletter, spec change label Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ed:spec Include in newsletter, spec change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not use successive steps for handling conditionals in algorithms
4 participants