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: Eliminate Lexical Environment #1697

Merged
merged 7 commits into from
Apr 23, 2020
Merged

Conversation

jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented Sep 16, 2019

... as suggested in PR #1473.

In effect, I've merged the concept/model of Lexical Environment into that of Environment Record. In my opinion, there's no point where the spec suffers from this merge. The only question is whether the improvement in the spec is worth the hassle of the transition.

The bulk of the change happens over the first 4 commits. Note that these commits are not logically separate -- the intermediate versions of the spec are not self-consistent. The only reason I separated them is to make it somewhat easier for someone who wants to check my work. You'd probably want to squash them when merging.

The last three commits are convenient add-ons.

Downstream effects:

  • HTML appears to be unaffected.
  • WebIDL doesn't refer to Lexical Environments explcitly, but does involve them implicitly. Fixing this would mostly amount to changing X's EnvironmentRecord to just X.

@devsnek
Copy link
Member

devsnek commented Sep 16, 2019

i'll try to get this tested in engine262 before the end of the week

@jmdyck
Copy link
Collaborator Author

jmdyck commented Oct 14, 2019

(force-pushed to resolve merge conflicts from PR #1670 and PR #1725)

@jmdyck
Copy link
Collaborator Author

jmdyck commented Oct 24, 2019

(force-pushed to resolve merge conflicts from PR #1740 and PR #1733)

@michaelficarra
Copy link
Member

I'm neutral on this change. Not everything that has a 1-to-1 relationship needs to be merged. It's also sometimes easier to not have bits you don't care about available to you.

I'd prefer we get #1477 in and later make a decision about whether we do this.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Oct 25, 2019

It's also sometimes easier to not have bits you don't care about available to you.

This sentence had me stumped for a while. Am I right in thinking that, in the context of this PR, "you" is an operation that deals with Environment Records, and the "bits you don't care about" is the 'outer environment reference' of the corresponding Lexical Environment?

@michaelficarra
Copy link
Member

Correct! Sorry for the loose phrasing.

spec.html Show resolved Hide resolved
@bergus
Copy link

bergus commented Nov 1, 2019

I'm not so fond of getting rid of the term "lexical". It serves as a good reminder that JS uses lexical scoping, and that this data structure is the representation of that model.
How about naming the new structure "Lexical Environment Record"? As a bonus, anyone searching for the old terms would find the new one :-) Alternatively, given @allenwb's suggestion, "Lexical Bindings Record"?

@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 4, 2019

How about naming the new structure "Lexical Environment Record"?

So then all the subtypes would add "Lexical"?

  • declarative Lexical Environment Record
  • function Lexical Environment Record
  • module Lexical Environment Record
  • object Lexical Environment Record
  • global Lexical Environment Record

@michaelficarra michaelficarra added the editor call to be discussed in the next editor call label Nov 4, 2019
@bergus
Copy link

bergus commented Nov 4, 2019

@jmdyck Oh, I completely forgot about that. Scrap the idea. An object environment record is definitely not lexical. At best, we could have the hierarchy

  • Environment Record
    • Lexical Environment Record
      • Function Environment Record
      • Module Environment Record
    • Object Environment Record
    • Global Environment Record

where the term "lexical" now replaced "declarative", for no good reason.

@devsnek
Copy link
Member

devsnek commented Nov 5, 2019

https://tc39.es/ecma262/#sec-globalthis needs to be updated too

@devsnek
Copy link
Member

devsnek commented Nov 5, 2019

With the change for globalThis, this patchset is passing test262 on engine262 :)

@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 6, 2019

https://tc39.es/ecma262/#sec-globalthis needs to be updated too

Whoops, that snuck in on a rebase. Thanks for catching it.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 6, 2019

Added 2 commits:

  • Fix globalThis (pointed out by @devsnek).
  • Fix "Changes to EvalDeclarationInstantiation" (I noticed while reviewing).

Conceptually, these both fit in this PR's second commit ("Merge Lexical Environment into Environment Record"), but I kept them separate rather than squashing them in because I'm expecting all the commits will be squashed on merge anyway (if this PR is accepted).

@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 6, 2019

Added a commit to fix another change that snuck in on a rebase.

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.

The contents lgtm. At the end of the day I am also pretty neutral on the change. I'll bring it up at the next editor call to try to get a less tepid temperature.

@ljharb ljharb requested review from michaelficarra and bakkot and removed request for jasonwilliams and zenparsing November 13, 2019 22:54
…c39#1697)

(currently attached to Lexical Environment, but that will change)
…ithms (tc39#1697)

Mostly this amounts to erasing the distinction
between _LE_ and "_LE_'s EnvironmentRecord".

For the merged thing, I always used the metavariable/alias
that had formerly been used for the Lexical Environment,
even though this sometimes resulted in more diff lines.
…1697)

... mostly by changing "Lexical Environment" to "Environment Record".

For lowercase "lexical environment", the treatment varies,
because it's used with a few senses:
  - same as uppercase,
  - the LexicalEnvironment component of an execution context, and
  - the general (non-ES-specific) sense.
…9#1697)

(except for function Environment Record, which already has one)
)

... for _realm_.[[GlobalEnv]] and _module_.[[Environment]]
@ljharb ljharb merged commit 0b988b7 into tc39:master Apr 23, 2020
@ljharb
Copy link
Member

ljharb commented Apr 24, 2020

@jmdyck apologies on not giving you the heads up you asked for; please feel free to make a quick followup for final touches

@jmdyck
Copy link
Collaborator Author

jmdyck commented Apr 24, 2020

It looks like nothing else snuck in on a rebase, but I did notice something minor that I should have changed, so I'll add that to #1965.

jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Apr 24, 2020
... in FunctionDeclarationInstantiation,
to balance the NOTE in the other arm of the if-else,
and also for consistency with the NOTE at 27.a.

(I should have done this in PR tc39#1697.)
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Apr 30, 2020
... in FunctionDeclarationInstantiation,
to balance the NOTE in the other arm of the if-else,
and also for consistency with the NOTE at 27.a.

(I should have done this in PR tc39#1697.)
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request May 1, 2020
... in FunctionDeclarationInstantiation,
to balance the NOTE in the other arm of the if-else,
and also for consistency with the NOTE at 27.a.

(I should have done this in PR tc39#1697.)
@jmdyck jmdyck deleted the eliminate-lex-env branch May 1, 2020 22:01
ljharb pushed a commit to jmdyck/ecma262 that referenced this pull request May 6, 2020
Editorial: Reinstate an SDO rule

PR tc39#1933 deleted SDO rules that are handled by the chain production rule,
but it also deleted this one which isn't.
(It has "TV" on the left and "TRV" on the right.)

Editorial: Move an <emu-note> element

PR tc39#1490 (among other things) moved the evaluation semantics for ArrowFunction
from the Evaluation SDO to the NamedEvaluation SDO.
The accompanying <emu-note> should have moved at the same time
(in particular because of the reference to "step 3").

Editorial: Delete <emu-note> in TimeClip clause

PR tc39#1827 (among other things) removed step 4 from the algorithm for TimeClip,
obsoleting the accompanying emu-note that describes "the point of step 4".

Conceivably, the note could be reworded to describe the effect of
'ToInteger' on step 3, but I don't think it'd be worth the bother.

Editorial: Change "Step 2.a" to "Step 2.b" in RepeatMatcher note

PR tc39#1889 (among other things) inserted a step before the former 2.a,
but didn't update the note that referenced it.

Editorial: Change step 7 to step 6 in SortCompare note

Commit 9c1e076 (2015-10-26) introduced the '?' abbreviation for ReturnIfAbrupt.
This caused the ToString call on step 7 to move to step 6,
but the note that referred to it wasn't updated.

Editorial: Fix typo: "Descritor" -> "Descriptor"

Editorial: Fix typo: "GeneratorObject" -> "generator object"

(There's no such thing as a GeneratorObject.)

Editorial: Delete "as a parameter" after "is present"

(It's the only place in the spec where we use that phrasing.)

Editorial: Change "which" to "that"

... in "{String,Array,Map,Set} methods which return such iterators"

Editorial: Insert a comma in SetDefaultGlobalBindings()

Formerly, it read like "containing" modified "the property",
when it actually modified "the property descriptor".

Editorial: Change "lexical environment" to "Environment Record"

... in FunctionDeclarationInstantiation,
to balance the NOTE in the other arm of the if-else,
and also for consistency with the NOTE at 27.a.

(I should have done this in PR tc39#1697.)

Editorial: Change "step 3" to "step 4" in Note

... that accompanies the NamedEvaluation semantics for
    ArrowFunction : ArrowParameters `=&gt;` ConciseBody

PR tc39#1870 (among other things) inserted a step before the former step 3,
but didn't update the note that referenced it.
js-choi added a commit to tc39/proposal-hack-pipes that referenced this pull request Mar 12, 2021
See tc39/ecma262#1697.
Also improve cross-references to |PipelineTopicBody|.
jmdyck added a commit to jmdyck/html that referenced this pull request Jan 26, 2022
Formerly, 7.3 "The Window object" referred to
`(realm).[[GlobalEnv]]'s EnvironmentRecord's [[GlobalThisValue]]`
Here, `(realm).[[GlobalEnv]]` was a Lexical Environment,
whose `EnvironmentRecord` component was a global Environment Record,
with a `[[GlobalThisValue]]` field.

However, tc39/ecma262#1697 eliminated Lexical Environments,
merging them into Environment Records.
So now `(realm).[[GlobalEnv]]` is a global Environment Record.
jmdyck added a commit to jmdyck/html that referenced this pull request Jan 26, 2022
Formerly, 7.3 "The Window object" referred to
`(realm).[[GlobalEnv]]'s EnvironmentRecord's [[GlobalThisValue]]`
Here, `(realm).[[GlobalEnv]]` was a Lexical Environment,
whose `EnvironmentRecord` component was a global Environment Record,
with a `[[GlobalThisValue]]` field.

However, tc39/ecma262#1697 eliminated Lexical Environments,
merging them into Environment Records.
So now `(realm).[[GlobalEnv]]` is a global Environment Record.
jmdyck added a commit to jmdyck/html that referenced this pull request Jan 26, 2022
Formerly, 7.3 "The Window object" referred to
`(realm).[[GlobalEnv]]'s EnvironmentRecord's [[GlobalThisValue]]`
Here, `(realm).[[GlobalEnv]]` was a Lexical Environment,
whose `EnvironmentRecord` component was a global Environment Record,
with a `[[GlobalThisValue]]` field.

However, tc39/ecma262#1697 eliminated Lexical Environments,
merging them into Environment Records.
So now `(realm).[[GlobalEnv]]` is a global Environment Record,
and the reference should be
`(realm).[[GlobalEnv]].[[GlobalThisValue]]`
annevk pushed a commit to whatwg/html that referenced this pull request Jan 26, 2022
See tc39/ecma262#1697 for context. Also adjust the style as per Web IDL.
asankah pushed a commit to asankah/html that referenced this pull request Feb 7, 2022
See tc39/ecma262#1697 for context. Also adjust the style as per Web IDL.
mfreed7 pushed a commit to mfreed7/html that referenced this pull request Jun 3, 2022
See tc39/ecma262#1697 for context. Also adjust the style as per Web IDL.
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.

7 participants