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

String interpolation unaware of macro-local variables #1557

Closed
jacg opened this issue Nov 16, 2012 · 5 comments
Closed

String interpolation unaware of macro-local variables #1557

jacg opened this issue Nov 16, 2012 · 5 comments
Assignees
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@jacg
Copy link

jacg commented Nov 16, 2012

This simple macro

macro foo ()
    quote
        a = 1
        println("a = ", a)
        println("a = $a")
    end
end

when expanded

println(macroexpand(:(@foo)))

gives

quote   #  line 3:
    #2 = 1  #  line 4:
    println("a = ", #2) #  line 5:
    println($(Base).sprint($(print), "a = ", a))
end

Consequently

@foo

gives

a = 1
a not defined
@JeffBezanson
Copy link
Sponsor Member

Oh how I hate string interpolation.

@StefanKarpinski
Copy link
Sponsor Member

Worst incredibly useful feature ever ;-)

@JeffBezanson
Copy link
Sponsor Member

Only fix I can really think of is to expand @str before the renaming pass as a special case.

@JeffBezanson
Copy link
Sponsor Member

By the way, imagine what it would be like to use string interpolation with gensyms. It would be so awkward that this issue wouldn't have even arisen :) It would be better to expand string interpolations at parse time maybe. Better still to get rid of them.

@ghost ghost assigned JeffBezanson Nov 19, 2012
@StefanKarpinski
Copy link
Sponsor Member

I would be willing to expand @str before the renaming pass. Another option would be to make interpolation into normal strings more baked into the language and thereby possibly address #455, which probably shouldn't really be closed since it's resolution depends on triple-quotes, which we don't yet have.

fredrikekre pushed a commit that referenced this issue Dec 23, 2019
…34186)

$ git log --oneline 8e236a7f993f1e732ffd0ab5c15736b2594e4109^..6c29d6c5421b4e3d872ccf42bd775b627b300069
6c29d6c provide a fallback when sandboxing projects with no project file (#1549)
b9bcd6a Do not ever attempt to set owner when extracting (#1557)
50581b2 Add try/catch around call to realpath in safe_realpath (#1547)
fb248f4 Remove Test which was added as a dependency by accident (#1553)
180d51e Disable needless specialization in Artifacts code (#1543)
7e42dfa telemetry: remove commit header (#1551)
a9d85e7 Adjust GC delay and add `--all` flag to circumvent delay (#1540)
8e236a7 Merge pull request #1544 from JuliaLang/sk/telemetry
90b8482 telemetry: factor out telemetry file loading
228fb97 CI telemetry: send indicators for common CI env vars
246dbd0 Pkg protocol: basic anonymous opt-out telemetry
KristofferC pushed a commit that referenced this issue Apr 11, 2020
…34186)

$ git log --oneline 8e236a7f993f1e732ffd0ab5c15736b2594e4109^..6c29d6c5421b4e3d872ccf42bd775b627b300069
6c29d6c provide a fallback when sandboxing projects with no project file (#1549)
b9bcd6a Do not ever attempt to set owner when extracting (#1557)
50581b2 Add try/catch around call to realpath in safe_realpath (#1547)
fb248f4 Remove Test which was added as a dependency by accident (#1553)
180d51e Disable needless specialization in Artifacts code (#1543)
7e42dfa telemetry: remove commit header (#1551)
a9d85e7 Adjust GC delay and add `--all` flag to circumvent delay (#1540)
8e236a7 Merge pull request #1544 from JuliaLang/sk/telemetry
90b8482 telemetry: factor out telemetry file loading
228fb97 CI telemetry: send indicators for common CI env vars
246dbd0 Pkg protocol: basic anonymous opt-out telemetry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants