Parametric or normal types for dispatching on materials

When generating a type representing a material would it be better to generate types for every material or to create a parametric material type.

What would you suggest and why?

abstract type Material end
struct Gold <: Material end
isMetal(::Gold) = true
struct Material{T} end
const Gold = Material{:Gold}
isMetal(::Gold) = true
1 Like

Unless you want to compile specific code for each material, I would just store properties in a struct. Eg

struct Material
    # ... surely it has other fields
const Gold = Material(true) # look at Base.@kwdef


1 Like