Skip to content

Conversation

@ahejlsberg
Copy link
Member

With this PR we always ensure that temporary names are unique in the source file. This is cheaper than using resolveName to ensure uniqueness, plus it is easier to reason about and safer in cases where we didn't reason right.

I also combined the dedicated _i and _n tracking flags and the temp variable counter in a single variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

We still need to get rid of _n, but that can be a separate change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this better than the TempVariableKind we had previously?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's better because it is all in a single tempFlags variable.

@JsonFreeman
Copy link
Contributor

👍, once comments are addressed

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems overly dense. It took me several reads just to figure out what it was doing. Can we simplify is as something more like

let set = generatedNameSet || (generatedNameSet = {});
set[generatedName] = generatedName;

This helps break out the different concerns. I.e. lazily initializing the set, and adding the element to the set.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 27, 2015

👍

ahejlsberg added a commit that referenced this pull request Mar 27, 2015
Simplify temporary name generation logic
@ahejlsberg ahejlsberg merged commit 4894fee into master Mar 27, 2015
@ahejlsberg ahejlsberg deleted the simplifyTempLogic branch March 27, 2015 17:24
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants