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 TemplateStrings SDO #2893

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented Sep 4, 2022

... to separately handle

  • NoSubstitutionTemplate,
  • TemplateHead,
  • TemplateMiddle, and
  • TemplateTail.

This separates all the _raw_/TV/TRV stuff from the list-concatenation stuff, which I think makes it easier to see what's going on.

(I don't think GitHub's diff is very helpful for this one.)

Copy link
Contributor

@bakkot bakkot left a comment

Choose a reason for hiding this comment

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

This is definitely better. I am a little bit tempted to further introduce a TemplateString AO for the base cases, but it's probably not worth the overhead.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Sep 5, 2022

Hmm. Might be worth it...

@bakkot
Copy link
Contributor

bakkot commented Sep 5, 2022

If you're inclined to do that refactoring, I wouldn't say no to it.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Sep 5, 2022

Is this what you had in mind? I think it's an improvement, but it's debatable.

There's 3 different places where the « » could be applied:

  • within TemplateString,
  • around each invocation of TemplateString,
  • in the list-concatenation step (as in the current spec).

Currently I'm doing the middle one. Do you have a preference?

@bakkot
Copy link
Contributor

bakkot commented Sep 5, 2022

Yup, that's what I had in mind, and yes, I think putting the list wrapping around each invocation is the way to go.

@jmdyck jmdyck force-pushed the TemplateStrings_refactor branch from 6470245 to 313acd4 Compare September 7, 2022 21:26
@jmdyck
Copy link
Collaborator Author

jmdyck commented Sep 7, 2022

(force-pushed to take a more logical path to the same endpoint)

Copy link
Contributor

@syg syg left a comment

Choose a reason for hiding this comment

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

lgtm!

@syg syg added the ready to merge Editors believe this PR needs no further reviews, and is ready to land. label Sep 28, 2022
@jmdyck jmdyck force-pushed the TemplateStrings_refactor branch from 313acd4 to 778890b Compare September 29, 2022 00:04
@jmdyck
Copy link
Collaborator Author

jmdyck commented Sep 29, 2022

(force-pushed to squash 3 commits down to 1)

(1)
Factor out new AO TemplateString.

(2)
Move `« ... »` from the list-concatenation step
to instead surround the call to TemplateString.

(3)
Do some simple inlining, from:
    1. Let _x_ be TemplateString(|Y|, _raw_).
    1. Return « _x_ ».
to:
    1. Return « TemplateString(|Y|, _raw_) ».
@ljharb ljharb force-pushed the TemplateStrings_refactor branch from 778890b to 415600f Compare September 29, 2022 05:42
@ljharb ljharb merged commit 415600f into tc39:main Sep 29, 2022
@jmdyck jmdyck deleted the TemplateStrings_refactor branch September 29, 2022 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial change ready to merge Editors believe this PR needs no further reviews, and is ready to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants