zarldev / goenums

Type Safe Enum generator for Go
MIT License
222 stars 10 forks source link

not exporting map of enum values but exporting raw symbols instead #11

Closed nikolaydubina closed 5 months ago

nikolaydubina commented 6 months ago

motivation is three-fold:

  1. performance for access value from map may be worse than access from var. this is for inlining. my hunch is that compiler can inline var but can not inline field stored inside map.
  2. someone can override values in map. (albeit they can override values of exported var-s too, but that is more strange)
  3. code editors should be able to detect type better in type hints if it is exported as var and not inside map. (likely)

maybe I am missing something! just unusual to see enums exported inside map.

here is one very good enum: https://github.com/ferdypruis/iso4217 (it has map internally, but does not expose it) but eventually I moved away from map into just var symbols: http://github.com/nikolaydubina/fpmoney

zarldev commented 5 months ago

Use of container struct.