Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[typeid] Unify typed and untyped versions (#187)
## Summary Unifies typed and untyped versions of typeid. Basically we now have a single version of the library that uses generics. To support the "untyped" case where you might be dealing with an arbitrary (and unknown) prefix from a string, we have a special `AnyPrefix` type. A follow up PR will: make `Nil` equal to the empty struct. I also think I can incorporate Mike's changes so that they are optional (that way the user can choose whether they want to use reflection or not). Note that in order to fully support the "typed" and "untyped" cases, I often need to create two versions of a method: + The typed version *only* takes a Prefix Type, and it "infers" the prefix string from the type. + The untyped version takes the prefix as a string, and fixes the type of the typeid to `TypeID[AnyPrefix]` The main thing I'd like feedback on is whether we like this dual method approach, and whether we like the names I've picked. As an example, we used to have: ``` typeid.New("prefix") ``` But now there's: ``` typeid.New[PrefixType]() // and typeid.FromPrefix("prefix") ``` Do we like that? Do we prefer to keep the name `New("prefix")` for the "untyped" version, and introduce a new `NewTyped[Prefix]()` version? Similar questions happen between, say `FromUUID` and the new `FromUUIDPrefix`. ## How was it tested? All tests still pass.
- Loading branch information