Skip to content
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

Merged
merged 1 commit into from
Feb 20, 2017
Merged

Conversation

timholy
Copy link
Collaborator

@timholy timholy commented Feb 18, 2017

When someone tags this, it should probably be a minor version bump since it introduces a new deprecation.

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}}
Copy link
Owner

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?

Copy link
Collaborator Author

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.

Copy link
Owner

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.

Copy link
Collaborator Author

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.

Copy link

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

@mauro3 mauro3 merged commit 21a075b into master Feb 20, 2017
@mauro3
Copy link
Owner

mauro3 commented Feb 20, 2017

Thanks Tim!

@mauro3 mauro3 deleted the teh/IndexStyle branch February 20, 2017 11:47
@timholy
Copy link
Collaborator Author

timholy commented Feb 20, 2017

OK to tag?

If you haven't set up your repos for attobot, it does make life easier.

@mauro3
Copy link
Owner

mauro3 commented Feb 21, 2017

Here it is: JuliaLang/METADATA.jl#8049

(Sometimes I need more prodding than the gentle hint you made in your first post ;-)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants