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

Change TypeVars in UnionAlls to print as var"" syntax #34888

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Feb 26, 2020

This changes unnamed type variables to print as valid syntax, via the var"" printing macro introduced in #32408, as part of addressing #34887.

For example, this makes Vector{<:Bool} print as a valid, syntactic expression:

julia> Vector{<:Bool}
Array{var"#s46",1} where var"#s46"<:Bool

I'm not totally in love with this approach, since it makes the types much more verbose, but it's a good first step towards resolving #34887. I don't feel confident enough to delve into the type creation to change the type variable's actual name when instantiating the UnionAll to be a valid identifier, as proposed in #34887.

This changes unnamed type variables to print as valid syntax, via the
`var""` printing macro.

For example, before this commit, `Vector{<:Bool}` printed as a
non-syntactic string:
```julia
julia> Vector{<:Bool}
Array{#s16,1} where #s16<:Bool
```

And now it prints as a valid, syntactic expression:
```julia
julia> Vector{<:Bool}
Array{var"#s46",1} where var"#s46"<:Bool
```
@JeffBezanson
Copy link
Member

Agreed on all counts --- this is a good improvement, but it would be better to use valid identifiers to begin with.

@Keno Keno merged commit c1059e7 into JuliaLang:master Feb 26, 2020
@NHDaly NHDaly deleted the nhd-unionall-typevar-show-syntactic branch February 27, 2020 03:33
ravibitsgoa pushed a commit to ravibitsgoa/julia that referenced this pull request Apr 9, 2020
This changes unnamed type variables to print as valid syntax, via the
`var""` printing macro.

For example, before this commit, `Vector{<:Bool}` printed as a
non-syntactic string:
```julia
julia> Vector{<:Bool}
Array{#s16,1} where #s16<:Bool
```

And now it prints as a valid, syntactic expression:
```julia
julia> Vector{<:Bool}
Array{var"#s46",1} where var"#s46"<:Bool
```
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
This changes unnamed type variables to print as valid syntax, via the
`var""` printing macro.

For example, before this commit, `Vector{<:Bool}` printed as a
non-syntactic string:
```julia
julia> Vector{<:Bool}
Array{#s16,1} where #s16<:Bool
```

And now it prints as a valid, syntactic expression:
```julia
julia> Vector{<:Bool}
Array{var"#s46",1} where var"#s46"<:Bool
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants