Description
At present, we export Base.fieldname
, which maps a field's index to its symbol. Although we have the inverse function, Base.fieldindex
, which maps a field's symbol to its index, defined and documented, we currently do not export it.
I have redefined this function multiple times on my own in the past and only recently discovered its existence in Base
. I propose that we export Base.fieldindex
, as doing so would enhance the consistency and completeness of the field introspection functions. Additionally, it is unlikely that the function will undergo fundamental changes in the future, so exporting it should not pose a significant maintenance burden. The interface is likely fully defined by the following two properties.
@test fieldname(Some{Int}, Base.fieldindex(Some{Int}, :value)) === :value
@test Base.fieldindex(Some{Int}, fieldname(Some{Int}, 1)) === 1
I created a PR, but exporting a new function might warrant some discussion first. I'll proceed with the PR once there is confirmation that exporting fieldindex
is acceptable. Please state if you think additional documentation or tests would make sense to export it.