Often in packages and Julia source code, I see structs that have no field. For example,
abstract type RangeStepStyle end
struct RangeStepRegular <: RangeStepStyle end # range with regular step
struct RangeStepIrregular <: RangeStepStyle end # range with rounding error
What’s the point of creating a type without any fields. How do you use these and how does this relate to type stability of the code?
You can also use type parameters like f(::NoFields{N}) where N = N == 0 will specialize the function on the type parameter. Because N is a type parameter, the value of N == 0 can be evaluated ahead of time during compilation before the function is actually called, thus eliminating the calculation at run time.