-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix IndexStyle and abstract depwarns on 0.6 #22
Conversation
b23ebd2
to
89e52b4
Compare
src/base-traits.jl
Outdated
IsAnything, IsNothing, IsCallable | ||
|
||
"Trait which contains all types" | ||
@traitdef IsAnything{X} | ||
@traitimpl IsAnything{X} <- (x->true)(X) | ||
|
||
"Trait which contains no types" | ||
typealias IsNothing{X} Not{IsAnything{X}} | ||
@compat IsNothing{X} = Not{IsAnything{X}} |
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.
Is there no const
needed?
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.
It doesn't appear to be necessary (see Julia's NEWS.md file), but it doesn't seem to hurt either. Most but not all of them in https://github.com/JuliaLang/julia/pull/20500/files seem to use const
, so I can add it if you prefer.
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.
That NEWS.md entry is a bit confusing. Anyway, it does seem to make a difference (unless something changed on 0.6 in the last 5 days):
julia> V = Int
Int64
julia> f() = convert(V,5.0)
f (generic function with 1 method)
julia> @code_warntype f()
Variables:
#self#::#f
Body:
begin
return (Main.convert)(Main.V, 5.0)::Any
end::Any
julia> const VV = Int
Int64
julia> ff() = convert(VV,5.0)
ff (generic function with 1 method)
julia> @code_warntype ff()
Variables:
#self#::#ff
Body:
begin
return $(Expr(:invoke, MethodInstance for convert(::Type{Int64}, ::Float64), :(Main.convert), :(Main.VV), 5.0))
end::Int64
So, probably better add the const
.
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.
Parametric types seem different:
julia> MyVector{T} = AbstractArray{T, 1}
AbstractArray{T,1} where T
julia> f(a) = convert(MyVector, a)
f (generic function with 1 method)
julia> @code_warntype f([1,2,3])
Variables:
#self#::#f
a::Array{Int64,1}
Body:
begin
return a::Array{Int64,1}
end::Array{Int64,1}
but nevertheless I'll add the const
.
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.
the const is implicit for parametric type aliases, but IMO a useful signal about what the line is doing
89e52b4
to
92bd3b5
Compare
Thanks Tim! |
OK to tag? If you haven't set up your repos for attobot, it does make life easier. |
Here it is: JuliaLang/METADATA.jl#8049 (Sometimes I need more prodding than the gentle hint you made in your first post ;-) |
When someone tags this, it should probably be a minor version bump since it introduces a new deprecation.