You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstract type Parent end
mutable struct Child1 <: Parent
type # Set to 'child1'
end
mutable struct Child2{N<:Integer} <: Parent
type # Set to 'child2'
i::N
end
StructTypes.StructType(::Type{Parent}) = StructTypes.AbstractType()
StructTypes.StructType(::Type{Child1}) = StructTypes.Mutable()
StructTypes.StructType(::Type{<:Child2}) = StructTypes.Mutable()
StructTypes.subtypekey(::Type{Parent}) = :type
StructTypes.subtypes(::Type{Parent}) = (child1=Child1, child2=Child2)
Currently, afaik, there is no mechanism for StructTypes to serialize/deserialize the value of N, like how it can write the type key for each child.
Current workarounds I can think of:
Pick a unique type name for each concrete version of Child2{N} you expect to be possible: (child1=Child1, child2U8=Child2{UInt8}, child2I32=Child2{Int32}, ...)
Use UnorderedStruct or OrderedStruct instead of Mutable, and let the type parameter be inferred by the constructor.
Would it be feasible to support deserializing type parameters in the same way as the type itself? For example:
struct Child2{N<:Integer} <: Parent
type # Set to 'child2'
int_type::Type # Set to string(N)
i::N
end
StructTypes.parametrickey(::Type{<:Child2}, ::Val{1}) = :int_type
The text was updated successfully, but these errors were encountered:
Let's say I have a type hierarchy like this:
Currently, afaik, there is no mechanism for
StructTypes
to serialize/deserialize the value ofN
, like how it can write thetype
key for each child.Current workarounds I can think of:
type
name for each concrete version ofChild2{N}
you expect to be possible:(child1=Child1, child2U8=Child2{UInt8}, child2I32=Child2{Int32}, ...)
UnorderedStruct
orOrderedStruct
instead ofMutable
, and let the type parameter be inferred by the constructor.Would it be feasible to support deserializing type parameters in the same way as the type itself? For example:
The text was updated successfully, but these errors were encountered: