Re: [julia-users] Circular parametric types

2016-01-28 Thread Tommy Hofmann
This is now https://github.com/JuliaLang/julia/issues/14825 On Wednesday, January 27, 2016 at 4:52:00 PM UTC+1, Yichao Yu wrote: > > On Wed, Jan 27, 2016 at 10:35 AM, Tommy Hofmann > wrote: > > I am trying to define two parametric types with circular dependency as > >

Re: [julia-users] Circular parametric types

2016-01-28 Thread Tommy Hofmann
On Thursday, January 28, 2016 at 12:23:34 PM UTC+1, Toivo Henningsson wrote: > > Yes, you're right! I guess that you would have to break the chain at some > point with Any or similar, which doesn't feel quite satisfying. But maybe > it's the best that you can do for now. > > In your code, when

Re: [julia-users] Circular parametric types

2016-01-28 Thread Toivo Henningsson
In the meantime, you can relax the second type definition to type t2{C, T} <: abstest x::C y::T end which will allow you to construct all the parametric types that you want, plus some more. You could add a check in the t2 constructor to make sure that T meets your expectations.

Re: [julia-users] Circular parametric types

2016-01-28 Thread Tommy Hofmann
On Thursday, January 28, 2016 at 10:57:59 AM UTC+1, Toivo Henningsson wrote: > > In the meantime, you can relax the second type definition to > > type t2{C, T} <: abstest > x::C > y::T > end > > which will allow you to construct all the parametric types that you want, > plus some more. You

Re: [julia-users] Circular parametric types

2016-01-28 Thread Toivo Henningsson
Yes, you're right! I guess that you would have to break the chain at some point with Any or similar, which doesn't feel quite satisfying. But maybe it's the best that you can do for now. In your code, when you access fields that are not typed as strictly as you want, at least you can put in a

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
Are circular type trees supposed to work? We can't even join types: *abstract A* *abstract B* *type D <: Union{A, B} # Fail* *end*

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
*typealias D Union{A,B}* *julia> **D <: Union{A,B}* *true* *;) thanks*

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
Whoops. Can I get editing permission for my own posts?

Re: [julia-users] Circular parametric types

2016-01-27 Thread Stefan Karpinski
"even" On Wed, Jan 27, 2016 at 8:43 PM, Bryan Rivera wrote: > Are circular type trees supposed to work? > > We can't even join types: > > *abstract A* > > *abstract B* > > *type D <: Union{A, B} # Fail* > > *end* >

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
*typealias D Union{A,B}* *julia> **D <: Union{A,B}* *true* *Is this what you meant?* *So if the example code is a bug, does this mean Julia should have a recursive type tree?*

Re: [julia-users] Circular parametric types

2016-01-27 Thread Yichao Yu
On Wed, Jan 27, 2016 at 10:35 AM, Tommy Hofmann wrote: > I am trying to define two parametric types with circular dependency as > follows. > > abstract abstest > > type t1{A <: abstest, B} > x::A > y::B > end > > type t2{C, B} <: abstest > x::C > y::t1{t2{C, B}, B} > end