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

grabbag of subtyping punchlist items #20407

Merged
merged 13 commits into from
Feb 11, 2017
Merged

grabbag of subtyping punchlist items #20407

merged 13 commits into from
Feb 11, 2017

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Feb 2, 2017

From the list in #19998. Will check those off when this is merged.

@ararslan ararslan added the types and dispatch Types, subtyping and method dispatch label Feb 2, 2017
@@ -1045,6 +1045,10 @@ end
Of course, this depends on what `Int` is aliased to -- but that is predefined to be the correct
type -- either `Int32` or `Int64`.

(Note that unlike `Int`, `Float` does not exist as a type-alias for a specific sized `AbstractFloat`.
Unlike with integer registers, the size of the floating point representation is problem dependent,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integer sizes often need to be problem dependent too, I'm not sure this is the right wording to justify this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Maybe I should say something along the lines of "the floating point register sizes are standardized across CPUs based on the IEEE-754 standard."?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

practically speaking I'd say that's more accurately the reason

@@ -42,3 +42,6 @@ Extended documentation for mathematical symbols & functions is [here](@ref math-
| `::` | type annotation, depending on context |
| `:( )` | quoted expression |
| `:a` | symbol a |
| `<:` | [`subtype operator`](@ref <:) |
| `>:` | [`supertype operator`](@ref >:) (reverse of subtype operator) |
| `===` | [`eqal comparison operator`](@ref ===) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eqal or egal?

base/show.jl Outdated
#The same as `IOContext(io::IO, KV::Pair)`, but accepting properties as keyword arguments.
#"""
#IOContext(io::IO; kws...) = IOContext(IOContext(io); kws...)
#function IOContext(io::IOContext; kws...)
Copy link
Contributor

@tkelman tkelman Feb 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might break Documenter, Juno, IJulia, SHA and others, is it possible to deprecate this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not easily. The problem is that it replaces the primitive IOContext(io) constructor (which would otherwise be inlined), with several kwarg calls. (since the kwarg method needs to be the same as the no-keyword args function)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the commit message should say "remove keyword argument IOContext constructors". That's a pretty sneaky thing to combine with an implementation-only change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seriously – this is not non-breaking...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean sneaky like the commit message that added the alternate constructor? "use IOContext more consistently" (ce23174)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately there's a ratchet effect. Adding a feature or method doesn't break anything, but removing one does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why does the performance of this constructor matter?


Supertype operator, equivalent to `issubtype(T2, T1)`.
"""
const (>:)(a::ANY, b::ANY) = issubtype(b, a)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs special inference support to be able to infer Const(true) or Const(false).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably doable, and perhaps not a bad idea anyways (so that it doesn't attempt to actually specialize on any arguments that it sees). I guess the idea is that it's preferable to ensure >: and <: behave the same. Should I make both of them (issupertype) builtins to keep it identical, or just make it close enough via inference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not add more builtins; let's just add it to inference.

base/show.jl Outdated
#The same as `IOContext(io::IO, KV::Pair)`, but accepting properties as keyword arguments.
#"""
#IOContext(io::IO; kws...) = IOContext(IOContext(io); kws...)
#function IOContext(io::IOContext; kws...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the commit message should say "remove keyword argument IOContext constructors". That's a pretty sneaky thing to combine with an implementation-only change.

@vtjnash vtjnash force-pushed the jn/grabbag-subtypes branch 2 times, most recently from 22534b4 to 90357c3 Compare February 6, 2017 23:32
...by removing it.
This type can't be represented in Julia correctly,
but it also isn't needed.
Since UnionAll bounds are encountered recursively,
it's easiest to represent this the same way in the IOContext.

Also avoid the performance / allocation overhead of using
`IOContext(io)` as a no-op convert (not a no-op since keyword support was added)
the previous version was effectively equivalent, but did more work than necessary
and could fail in the wrong direction in the unlikely case that `ambi` was not a strict subtype of `mambig->sig`.
Seems to be a common FAQ. Not sure if those users would have seen it here,
but it's right after explaining the existance of the `Int` type-alias.
the general inliner is better and also respects effect_free

(related to #9765, although none of these specific cases were mentioned there)
@vtjnash vtjnash force-pushed the jn/grabbag-subtypes branch from 90357c3 to 0c819fe Compare February 7, 2017 16:43
@vtjnash
Copy link
Member Author

vtjnash commented Feb 9, 2017

bump

test/show.jl Outdated
@@ -569,7 +569,7 @@ let repr = sprint(dump, Any)
@test length(repr) > 100000
@test ismatch(r"^Any\n [^ \t\n]", repr)
@test endswith(repr, '\n')
@test_broken contains(repr, " Base.Vector{T} = Array{T,1}\n")
@test contains(repr, " Base.Vector{T} = Array{T,1} where T\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more accurate print either Base.Vector = Array{T,1} where T or Base.Vector{T} = Array{T,1}. That second syntax will be added soon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@JeffBezanson
Copy link
Member

LGTM.

@KristofferC
Copy link
Member

@nanosoldier runbenchmarks(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

@vtjnash vtjnash merged commit 6fa37f6 into master Feb 11, 2017
@vtjnash vtjnash deleted the jn/grabbag-subtypes branch February 11, 2017 01:53
@tkelman
Copy link
Contributor

tkelman commented Feb 11, 2017

the comprehension slowdown there looks like it could be real

@felixrehren felixrehren mentioned this pull request Feb 16, 2017
53 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants