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

add some needed local declarations to macros #37219

Merged
merged 1 commit into from
Aug 27, 2020
Merged

Conversation

JeffBezanson
Copy link
Sponsor Member

to avoid leaking globals

base/logging.jl Outdated
file = $(log_data._file)
line = $(log_data._line)
local file = $(log_data._file)
local line = $(log_data._line)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

guess we can wrap the entire block into let instead of adding bunch of locals ? I hope it would look simpler

Comment on lines +646 to +647
push!(lowering, :(local $sym = $(GlobalRef(Base, :cconvert))($etype, $earg)))
push!(lowering, :(local $sym2 = $(GlobalRef(Base, :unsafe_convert))($etype, $sym)))
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

another nit pick, why can't we directly interpolate functions ?

Suggested change
push!(lowering, :(local $sym = $(GlobalRef(Base, :cconvert))($etype, $earg)))
push!(lowering, :(local $sym2 = $(GlobalRef(Base, :unsafe_convert))($etype, $sym)))
push!(lowering, :(local $sym = $(Base.cconvert)($etype, $earg)))
push!(lowering, :(local $sym2 = $(Base.unsafe_convert)($etype, $sym)))

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

While we allow that, it's a bit of a misfeature. It's better for code to describe where an object comes from, or how it is computed, than to contain the object itself. One way to think of it is that code is a textual description, so it should only contain text.

@JeffBezanson JeffBezanson merged commit 19bc06a into master Aug 27, 2020
@JeffBezanson JeffBezanson deleted the jb/macrolocals branch August 27, 2020 15:49
simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Aug 29, 2020
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.

None yet

2 participants