Struct with block of missing fields

Lincoln_Hannah
Tue, 27 Jun 2023 02:38:36 +0000
General Usage

I’d like to have a struct like this.

@with_kw struct my_struct
    x; y; z

    a
    b=fb(a)
    c=fc(b)
    d=fd(c)
    e=fe(d)

    f=ff(e)
    g=fg(f)
    h=fh(g)
    i=fi(h)
end

That can be created in two ways

   my_struct(;x,y,z, a)
   my_struct(;x,y,z, f)

In the second case, fields a-e would all be missing.

Is this possible ? To allow a block of fields to be missing ?

The altenative is to use two structs. It seems nice to have it all in one though, even if half the fields are missing for many instances.

10 posts - 5 participants