How would you implement or replace Python-like class attributes?

You could use a const Ref to hold the data:

const GeneralRank = Ref(1)
rank(::Type{General}) = GeneralRank[]
rank(x::General) = rank(typeof(x))
set_rank!(::Type{General}, value) = GeneralRank[] = value
etc...
1 Like