-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Consider renaming @with
for ScopedValues
#52535
Comments
There are quite a few |
We do expect this to be widely used across the ecosystem once people can rely on it. It has also been started to be used through the compatibility package ScopedValues.jl so changing it does have a non-zero cost attached to it. |
I also find |
Saying that a new package whose explicit purpose is to provide backwards compatibility for an as-of-yet unreleased feature of Julia should trump usages of existing packages feels a bit odd. Why shouldn't the uses of existing packages (who already have a userbase! One likely wider than ScopedValues.jl) trump Base instead? Them having to change their code and potentially slate a breaking release has a "non-zero cost" attached to it as well, and I'd wager that cost is larger than that of ScopedValues.jl. |
I think the rule is that if you're using a name and you want a stability guarantee you need to import or qualify the name. It can be annoying for Anyway discussing the general policy of name priority should probably happen on Discourse rather than in the |
I think
I really can't imagine that many users will be using the new |
I think it is important that Base not choose an overly generic name for a specific operation. For example, to get the step size of a range, Base uses the name |
If package A depends on package B, then to avoid breakage when B adds new functions, package A should use the following pattern: module A
using B: foo, bar
# ...
end But is that even possible with Base? To my understanding, there is an implicit This general problem is a little depressing, because it means that if a package developer wants to follow semantic versioning, then, strictly speaking, they need to upper bound the version of Base julia, because any minor release of Base could break their package. |
Yes it works fine in general: julia> using ThreadsX: map
julia> parentmodule(map)
ThreadsX But this issue is for |
I think you missed the point of my comment. The point is that packages cannot protect themselves from breakage when Base introduces new names. Thus Base should be more cautious about adding new names, especially overly generic ones. And |
I don't think this is true. In a fresh REPL session: AdminisatorsMBP:Downloads dilum$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.0-DEV.1102 (2023-12-14)
_/ |\__'_|_|_|\__'_| | Commit e9b0fa11c99 (0 days old master)
|__/ |
julia> using DataFramesMeta: @with
help?> @with
@with(d, expr)
@with allows DataFrame columns keys to be referenced as symbols. In another fresh REPL session: AdminisatorsMBP:Downloads dilum$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.0-DEV.1102 (2023-12-14)
_/ |\__'_|_|_|\__'_| | Commit e9b0fa11c99 (0 days old master)
|__/ |
julia> module Foo
using DataFramesMeta: @with
end
Main.Foo
help?> Foo.@with
│ Warning
│
│ The following bindings may be internal; they may change or be removed in
│ future versions:
│
│ • Main.Foo.@with
@with(d, expr)
@with allows DataFrame columns keys to be referenced as symbols. Pkg status:
|
That's not the package protecting itself from breakage, that's the package user protecting themselves from breakage. The current status quo is that using DataFrames, DataFramesMeta
df = DataFrame(x = 1:2);
@with(df, :x .+ 1) Anyhow, I opened up an issue for the more general issue of package breakage from new exported names in minor releases of Base Julia: #52540. |
DataFramesMeta.jl is meant to be a REPL-package for data cleaning and data exploration, so even if Julia recommends against |
Irrespective of the wider discussion around the policy in Base, I want to thank @mbauman for digging up the concrete list of affected packages. Seeing as that is quite a number of packages, I think choosing a different name for To give a concrete suggestion: How about |
Disregard this. I had a misunderstanding about how name ambiguities occur. The problem arises with code like That being said, I still think that Base should be cautious about adding new names. And new names should be added at the appropriate level of genericness. In my opinion, the name |
fixes #52535 --------- Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com>
Shouldn't |
That makes sense, yes. |
Cross posting from the PR #53707: I don't think this is what we are looking for. using Base.ScopedValues
x = ScopedValue(1) It's the same pattern as the In #53628 (not merged yet) I did add a |
I believe |
Then the docs must be updated. It says,
|
Yes, I already updated that in PR #53628, but it hasn't been merged yet. |
fixes JuliaLang#52535 --------- Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com>
PR #50958 introduces the
@with
macro along with dynamic scoping generally.DataFramesMeta.jl, the data analysis package I maintain, currently exports our own
@with
and will have to re-name the macro before the Julia's v1.11 release.@with
is a very valuable name. It's short and clear. Considering this, having it's use-case forScopedValue
s only seems unnecessarily niche to me.Would it be possible to re-name the
with
and@with
to something that doesn't use such a short name?I'm not opposed to Julia Base taking over
with
and@with
in the abstract. But this seems like such a unique use-case that the costs don't outweigh the benefits.The text was updated successfully, but these errors were encountered: