I’m often unsure if write some functions at top-level or in a singleton object.
As example, I’ve noted the function
generateSequence in stdlib is at top-level, but probably it could be declared as
Sequence.generate. So why have you preferred this?
Essentially they are equivalent, but there are some differences:
- top-level declarations are directly available from the code completion list, so they should be easier to find
- top-level names can clash easily with other declarations
- declarations at top-level are simplier since they don’t require to nest elements inside an object.
So in your opinion what are the best practices to choose top level declarations?