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

Cannot call non-exported string macro using dot #14208

Closed
simonbyrne opened this issue Dec 1, 2015 · 5 comments
Closed

Cannot call non-exported string macro using dot #14208

simonbyrne opened this issue Dec 1, 2015 · 5 comments
Labels
parser Language parsing and surface syntax

Comments

@simonbyrne
Copy link
Contributor

A simple example:

module Foo
    macro bar_str(s)
        s
    end
end

Then:

julia> Foo.bar"aa"
ERROR: UndefVarError: bar not defined

The parser interprets this as implicit multiplication:

julia> macroexpand(:(Foo.bar"aa"))
:(Foo.bar * "aa")

Is this something we can change, or is it too baked into the parser?

@Keno
Copy link
Member

Keno commented Dec 1, 2015

+1, this should be changed for consistency with

julia> module foo
       macro bar(x)
       println(x)
       end
       end
foo

julia> @foo.bar 1
1

@simonbyrne simonbyrne changed the title Cannot call string macro inside a module Cannot call non-exported string macro using dot Dec 1, 2015
@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label Dec 1, 2015
@JeffBezanson
Copy link
Sponsor Member

This can be changed in the parser, fairly easily I think.

@JeffBezanson
Copy link
Sponsor Member

Though one wonders if we really want more ways to call un-exported things. Maybe you should have to write @Foo.bar_str("x")?

@simonbyrne
Copy link
Contributor Author

My use case is in RCall. We have a @rimport which creates a new module mirroring the R namespace, however R frequently uses dots in names. I have a string macro var which allows for use of names with dots in them, so I want to write something like:

@rimport base as rbase
rbase.var"as.data.frame"(x)

@JeffBezanson
Copy link
Sponsor Member

Dup of #6970.

TotalVerb added a commit to TotalVerb/julia that referenced this issue Oct 3, 2016
TotalVerb added a commit to TotalVerb/julia that referenced this issue Dec 7, 2016
simonbyrne pushed a commit that referenced this issue Dec 7, 2016
* Permit using string macro with "qualified" name

Close #6970.
Close #14208.

* Add NEWS, doc for string and command macros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

3 participants