-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Compat for at-vectorize_(1|2)arg deprecation #280
Conversation
We also need a better |
This is backwards. Should try to provide the new syntax if possible, not just move the old macro here. |
I know this is backward but that's the point. The issue is that even though packages can use the 0.5 broadcast syntax with
As the commit message says, this is basically an easy upgrade path for packages that uses the macro so that they can fix their own use of the vectorized form and make sure user code won't break with minimum change of code. |
The |
OK, the return type of the broadcast syntax is fixed in most cases. This makes it as good as comprehension on 0.3/0.4 although not as good as 0.5. |
Haven't added test for the splatting case yet, will do that later. |
What's the upgrade path? Packages can just replace uses of the vectorize macros with calls to broadcast. |
Not for packages that uses the macro to define public functions |
Is the problem just that the base deprecated version of the macro doesn't give deprecation warnings when you call the vectorized functions that it defines? We could change that. I don't think Compat should be a holding ground for deprecated code. |
No the issue is that the macro gives a depwarn when used.
That's not new and the alternative is to move the same code to all other packages. |
As it should, it's deprecated. There have only been a handful of cases of putting the deprecated version here, and those were due to major differences in what would work on old julia versions - functorize and Compat.ASCIIString. The deprecated macro now giving deprecation warnings isn't a good reason to put it here without the warnings. There's an easy workaround here of defining vectorized methods manually. |
That could be said for the macro before it was deprecate, as well as the aliases for string renaming. In fact, I was doing the string deprecation fix by defining the type in packages before all of them are available in Compat. The defining vectorized method manually is also not that "easy". For one, the deprecation should only be raised on 0.6 (if not more precise than that) so there has to be a version check. The broadcast / shape / promotion code is also different between versions so it's non-trivial to manually defining these functions in packages in a way that works on all julia versions. In general, I think this package should define common things that help people fixing depwarns. In most case that's by defining new functions on old julia versions. However, there are some cases when that's not possible and it should be ok to define necessary piece that helps in those cases. |
Also, being a clear import/qualified use from Compat, it's a clear self documentation that something can be removed when support for old julia version is dropped |
I don't think Compat should host code that's obsolete from the very start. The way in which this package is intended to help people fix deprecation warnings is by supporting the new syntax on old Julia versions. A LegacyMacros package under JuliaArchive would be a better place for things that are deprecated in base that you still want packages to use without changes. People should stop using these macros, that's the point of deprecating them. If we put them here they'll never die. |
I don't see why that's the case. I'm only saying that it's not easier to define those functions manually than what it was before it was deprecated. It was useful which is why people use it. And FWIW, whether the code is obsolete from the start has little to do with how the upgrade should be done, how many users exists does.
That's one way and happens to be what works most of the time. It's unfortunately not always the case.
That could be a good place for the As mentioned before, the correct upgrade path for a package that uses these macros is,
It is true that it can theoretically take one release cycle longer to be removed them from |
I wonder if it might be worth having an additional module |
Well, it's "compatibility" in that it's to make the code being able to run on multiple julia versions. I don't see why putting it in a module would help anything apart from making using Compat harder but if that makes people happy I can certainly do that. |
Putting it in a module keeps related items together, and I think this |
Also it's not always deprecated, only on 0.6 (to avoid breaking users, ref JuliaInterop/ZMQ.jl#109), so calling it |
Hmm right, that is an argument for keeping it in |
Very few users or package developers should be caring about deprecation warnings on 0.6-dev yet. By the time they do, a much simpler upgrade path is just not calling the base vectorize macro on 0.6-dev or newer. |
What's the "Base vectorize macro"? |
put the call to |
How is that different from manually defining the function in packages which I've already argued against above? |
Also, |
7f939ad
to
bb0303e
Compare
Deprecation warnings don't usually make much difference to bisectability. Migrating package code to the new syntax is the right way to get rid of the deprecations, and going through putting this code here is a distraction from accomplishing that. |
Return type of the broadcasting syntax with scalar input is fixed. Also add more tests. |
Because the base change is actually two sequential deprecations. Of course they are closely related which is why this might not need to stay for longer than base. Another potential reason is that Compat support more julia versions (3 now) than Base (only 1).
Good. As I said, this is exactly what this PR does. |
But with a different name from what master uses, which is confusing. |
In other words I think it should be called dep_vectorize_1arg here, and the functions it defines should also be deprecations on earlier julia versions if we really want people to move away from them. |
The Now if I use |
It'll be much longer than 30 lines but sure. |
It should deprecate the vectorized versions on 0.3 to 0.5 also. |
Actually maybe not assuming we want the right depwarn and can accept minor behavior difference. |
3245129
to
b670088
Compare
b670088
to
c6477a8
Compare
# of the deprecated vectorized function have migrated. | ||
# These macros should raise a depwarn when the `0.5` support is dropped from | ||
# `Compat` and be dropped when the support for `0.6` is dropped from `Compat`. | ||
export @dep_vectorize_1arg, @dep_vectorize_2arg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these aren't exported from base so I don't think they should be exported here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Do note that the version here and the version in base serves completely different purposes. The base version isn't a public API, this one is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make the base one more official, in which case packages could choose to call that on 0.6 instead of the one that throws a deprecation warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, a compatibility layer in base that doesn't work on multiple julia version isn't very useful.
Packages will have to do version check in order to use the macro in which case they might as well use the Compat version or break API on 0.6.
This will basically means that the @dep_*
macro needs to be kept in Base for one version longer than the @vectorize_
which I think is a worse choice, at least for compatibility layer, than putting them here.
54a37a7
to
062690b
Compare
The performance of the broadcast syntax should almost match that of comprehension on 0.4 and the same syntax on master now. The main reason it doesn't is due to |
062690b
to
8bb149e
Compare
Will merge later today. Note that this is backportable to 0.8.x if people want it on 0.3. |
Provide `Compat.@dep_vectorize_1arg` and `Compat.@dep_vectorize_2arg` as an upgrade path for packages.
Add much more tests to ensure the behavior of the broadcast syntax is as consistent as possible on different julia versions.
8bb149e
to
fbf0173
Compare
# Packages are expected to use this to maintain the old API until all users | ||
# of the deprecated vectorized function have migrated. | ||
# These macros should raise a depwarn when the `0.5` support is dropped from | ||
# `Compat` and be dropped when the support for `0.6` is dropped from `Compat`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't they raise a depwarn when 0.4 support is dropped? dot-call syntax is implemented in 0.5, so once people are using 0.5+ there is no need for @vectorize
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just the most conservative option since hypothetical a package that is deprecated on 0.6 but works on 0.5 don't need to remove the use of @dep_vectorize_
since @vectorize_
is not deprecated there. Hopefully packages will migrate fast enough and we don't need to worry about this too much....
Provide
Compat.@vectorize_1arg
andCompat.@vectorize_2arg
as an upgradepath for packages.