Stumped by a subtyping issue

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Stumped by a subtyping issue

Eric Davies
I am getting confusing behaviour with some complex type aliases while using Cxx.jl and I was hoping someone could point out what is going on.

These are the aliases:

typealias CppAWSErrorType{C, I<:Integer} CppTemplate{CppBaseType{Symbol("Aws::Client::AWSError")}, Tuple{CppEnum{C, I}}}
typealias
CppAWSError{C, I<:Integer, Q} CppRef{CppAWSErrorType{C, I}, Q}

...
aws_raw_error
= @cxx list_buckets_outcome->GetError()
thetype
= AWSCxx.CppAWSError{Symbol("Aws::S3::S3Errors"), Int32, (false, false, false)}

@test typeof(aws_raw_error) <: thetype  # success
@test typeof(aws_raw_error) == thetype  # success
@test isa(aws_raw_error, thetype)  # success
@test typeof(aws_raw_error) <: AWSCxx.CppAWSError  # failure
@test isa(aws_raw_error, AWSCxx.CppAWSError)  # failure

Can anyone help?
Reply | Threaded
Open this post in threaded view
|

Re: Stumped by a subtyping issue

vavasis
Eric,

Possibly the following paragraph from the Julia manual may be relevant.  This paragraph is an excerpt from the section on parametric type aliases in the chapter "Types."  I am quite familiar with this paragraph because I authored it in a PR it after I was burned by a similar issue!

-- Steve Vavasis


"This declaration of Vector creates a subtype relation Vector{Int} <: Vector. However, it is not always the case that a parametric typealias statement creates such a relation; for example, the statement:

typealias AA{T} Array{Array{T,1},1}
 

does not create the relation AA{Int} <: AA. The reason is that Array{Array{T,1},1} is not an abstract type at all; in fact, it is a concrete type describing a 1-dimensional array in which each entry is an object of type Array{T,1} for some value of T."






On Monday, October 31, 2016 at 7:43:58 PM UTC-4, Eric Davies wrote:
I am getting confusing behaviour with some complex type aliases while using Cxx.jl and I was hoping someone could point out what is going on.

These are the aliases:

typealias CppAWSErrorType{C, I<:Integer} CppTemplate{CppBaseType{Symbol("Aws::Client::AWSError")}, Tuple{CppEnum{C, I}}}
typealias
CppAWSError{C, I<:Integer, Q} CppRef{CppAWSErrorType{C, I}, Q}

...
aws_raw_error
= @cxx list_buckets_outcome->GetError()
thetype
= AWSCxx.CppAWSError{Symbol("Aws::S3::S3Errors"), Int32, (false, false, false)}

@test typeof(aws_raw_error) <: thetype  # success
@test typeof(aws_raw_error) == thetype  # success
@test isa(aws_raw_error, thetype)  # success
@test typeof(aws_raw_error) <: AWSCxx.CppAWSError  # failure
@test isa(aws_raw_error, AWSCxx.CppAWSError)  # failure

Can anyone help?
Reply | Threaded
Open this post in threaded view
|

Re: Stumped by a subtyping issue

Eric Davies
Thank you, that clears things up. And thanks for adding to the manual!

On Monday, 31 October 2016 21:16:27 UTC-5, [hidden email] wrote:
Eric,

Possibly the following paragraph from the Julia manual may be relevant.  This paragraph is an excerpt from the section on parametric type aliases in the chapter "Types."  I am quite familiar with this paragraph because I authored it in a PR it after I was burned by a similar issue!

-- Steve Vavasis


"This declaration of Vector creates a subtype relation Vector{Int} <: Vector. However, it is not always the case that a parametric typealias statement creates such a relation; for example, the statement:

typealias AA{T} Array{Array{T,1},1}
 

does not create the relation AA{Int} <: AA. The reason is that Array{Array{T,1},1} is not an abstract type at all; in fact, it is a concrete type describing a 1-dimensional array in which each entry is an object of type Array{T,1} for some value of T."






On Monday, October 31, 2016 at 7:43:58 PM UTC-4, Eric Davies wrote:
I am getting confusing behaviour with some complex type aliases while using Cxx.jl and I was hoping someone could point out what is going on.

These are the aliases:

typealias CppAWSErrorType{C, I<:Integer} CppTemplate{CppBaseType{Symbol("Aws::Client::AWSError")}, Tuple{CppEnum{C, I}}}
typealias
CppAWSError{C, I<:Integer, Q} CppRef{CppAWSErrorType{C, I}, Q}

...
aws_raw_error
= @cxx list_buckets_outcome->GetError()
thetype
= AWSCxx.CppAWSError{Symbol("Aws::S3::S3Errors"), Int32, (false, false, false)}

@test typeof(aws_raw_error) <: thetype  # success
@test typeof(aws_raw_error) == thetype  # success
@test isa(aws_raw_error, thetype)  # success
@test typeof(aws_raw_error) <: AWSCxx.CppAWSError  # failure
@test isa(aws_raw_error, AWSCxx.CppAWSError)  # failure

Can anyone help?