user2244350
user2244350

Reputation: 27

recursive type initialization in julia

I have a problem with those two structs I defined:

mutable struct QMDDnode{T}
  next::QMDDnode{T}
  ref::Int
  v::Int
  renormFactor::Int
  ident::Bool
  diag::Bool
  block::Bool
  symm::Bool
  c01::Bool
  computeSpecialMatricesFlag::Bool
  e::Array{T} # type QMDDedge
  QMDDnode()=(x=new();x.next=x;x.e=Array{QMDDedge,1}(4);x)
end

mutable struct QMDDedge
  p::QMDDnode{QMDDedge}
  w::Complex
  sentinel::Int
  QMDDedge()=(x=new();x.p=QMDDnode{QMDDedge}();x)
end

I'm trying to understand how to properly initialize them, writing the correct constructors. If I call

b = QMDDedge()

I have a quite well defined object "b", but the elements of array e[] are #undef.

Is there a proper way to initialize them?

thanks, Fausto

Upvotes: 0

Views: 282

Answers (1)

JohnB
JohnB

Reputation: 189

See Incomplete Initialization in the docs. (maybe LightGraphs.jl is what your looking for)

Upvotes: 1

Related Questions