How to make a vector of parametric composite types?

Thanks for this correction.

But there remains the issue with allocation and time for the vector of layers with this implementation:

abstract OptProp

immutable Al <: OptProp end
immutable Vac <: OptProp end

immutable Layer{T <: OptProp}
          material::Type{T}
          thickness::Float64
 end

@benchmark ml = [Layer(Al,0.0); Layer(Vac,0.0)]
BenchmarkTools.Trial: 
  memory estimate:  1.97 kb
  allocs estimate:  48
  --------------
  minimum time:     10.937 μs (0.00% GC)
  median time:      11.656 μs (0.00% GC)
  mean time:        11.802 μs (0.00% GC)
  maximum time:     72.133 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1
  time tolerance:   5.00%
  memory tolerance: 1.00%



While with

abstract OptProp

immutable Al <: OptProp end
immutable Vac <: OptProp end

immutable Layer
          material::OptProp
          thickness::Float64
 end

@benchmark ml = [Layer(Al(),0.0); Layer(Vac(),0.0)]
BenchmarkTools.Trial: 
  memory estimate:  160.00 bytes
  allocs estimate:  3
  --------------
  minimum time:     43.866 ns (0.00% GC)
  median time:      47.852 ns (0.00% GC)
  mean time:        61.659 ns (21.21% GC)
  maximum time:     2.199 μs (96.82% GC)
  --------------
  samples:          10000
  evals/sample:     990
  time tolerance:   5.00%
  memory tolerance: 1.00%

This is quite important for me, since I need to pass such multilayer structures to other functions that will compute reflectivity and other physical quantities.

Finally, doing the test with the permittivity function

function permittivity(x::Al)
              2
       end


I get

@benchmark permittivity(Al())
BenchmarkTools.Trial: 
  memory estimate:  0.00 bytes
  allocs estimate:  0
  --------------
  minimum time:     1.409 ns (0.00% GC)
  median time:      1.680 ns (0.00% GC)
  mean time:        1.711 ns (0.00% GC)
  maximum time:     90.449 ns (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1000
  time tolerance:   5.00%
  memory tolerance: 1.00%

Which is almost 10 times faster.