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

@with macro clashes with Base.@with in Julia 1.11+ #364

Open
tkemmer opened this issue Sep 21, 2023 · 8 comments
Open

@with macro clashes with Base.@with in Julia 1.11+ #364

tkemmer opened this issue Sep 21, 2023 · 8 comments

Comments

@tkemmer
Copy link

tkemmer commented Sep 21, 2023

Julia 1.11 is the first version to export Base.@with:

help?> @with
  @with vars... expr

  Macro version of with(f, vars...) but with expr instead of f function. This is similar to using with with a do block, but avoids creating a closure.

This causes a name conflict with DataFramesMeta.@with (i.e., error when the latter used in a module). MWE:

julia> module Foo
    using DataFrames, DataFramesMeta

    const df = DataFrame(a = [1, 2, 3])
    print() = @with df println.(:a)
end
WARNING: both DataFramesMeta and Base export "@with"; uses of it in module Foo must be qualified
ERROR: LoadError: UndefVarError: `@with` not defined
in expression starting at REPL[14]:6
@bkamins
Copy link
Member

bkamins commented Sep 21, 2023

This is indeed a problematic issue. Probably we need to un-export @with (and the question is if there is a sensible way to rename it).

@pdeffebach
Copy link
Collaborator

This is definitely a bummer. Honestly, it seems like a pretty niche application (apply a function with in a temporary context) to use for such an obvious name.

We should brainstorm a renaming.

R calls this feature attach, but I don't think that's a very good name and attach has a bad reputation in the R community (for reasons which don't apply to DataFramesMeta.jl).

@bkamins
Copy link
Member

bkamins commented Sep 21, 2023

I would go for withdf or with_df or with_dataframe. Since it is a metapackage probably sortest i.e. withdf is my preference. Also with such a name there is low risk of name clash in the future.

@pdeffebach
Copy link
Collaborator

Thats a good idea. And will likely be the answer.

@pdeffebach
Copy link
Collaborator

pdeffebach commented Sep 28, 2023

@bkamins I've thought about this and decided @attach is the best name. @withdf is awkward because people will write @withdf df begin ... (assuming they name their dataframe df).

Maybe @attaching?

@bkamins
Copy link
Member

bkamins commented Sep 28, 2023

@attach is OK (it is a common name, but hopefully with low risk of overlap.

@nathanrboyer
Copy link

That is a bummer that @with has to change. FWIW, I like the @withdf name better than @attach.

@withdf is awkward because people will write @withdf df begin ...

I understand that you don't like the repeated df df, but if you read it this way, I think it is natural: "With data frame df, begin ..." or "With data frame iris, begin ...".

@attach iris, in contrast, sounds like the end of the sentence: "Attach iris. Begin ...". This makes less sense to me, since attach doesn't feel like it needs begin.

@pdeffebach
Copy link
Collaborator

We could do @attaching but that's more characters.

@using would have been great, but of course that will confuse people a lot.

Maybe @from ? As in, when I see :x I know that column is from df.

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 a pull request may close this issue.

4 participants