[fixed_string] Why "fixed" rather than "static"?
Hi Everyone, First, I would like to thank Vinnie and Krystian for writing and sharing the library. While this is not a review, I would like to share a thought about the choice of name. Given that we have static_vector, which seems to be doing a similar thing, why was this library called fixed_string rather than static_string? I note that name fixed_string has some potential to mislead the users as it might imply that it is the size that is fixed (like "a string that always stores 2-letter country codes"). I am not saying that the name choice is wrong. I would just want to see the rationale. Regards, &rzej;
On Thu, Nov 28, 2019 at 12:56 AM Andrzej Krzemienski via Boost
why was this library called fixed_string?
It was a mistake. It was originally static_string (it came from beast[1]) but someone suggested changing it and I listened. Oh well. Regards [1] https://github.com/boostorg/beast/blob/0b68ed651b6bc7b681cf440ed6a220089e214...
why was this library called fixed_string rather than static_string?
I like the name fixed because when I put it together with the static keyword it seems like less of a mess: constexpr static static_vector... constexpr static fixed_vector... I will say I like how the second one reads and static has the connotation of lifetime implications that I'm not sure static_vector or static_string actually do (they're not some sort of shared global-like storage for a thing). I hope both get changed to "fixed", as "static" is a nightmare of overloaded meaning, maybe with an alias "template <...> using fixed_vector = static_vector<...>". (Or we just come up with an even better short word, but I have no ideas for that!) Still, existing practice is important... Best, JeanHeyd
On Thu, Nov 28, 2019 at 6:19 AM JeanHeyd Meneide
constexpr static static_vector... constexpr static fixed_vector...
Well, there's a good argument to be made that the primary template should be prefixed with basic_ so it would be constexpr static basic_static_string. Or even better constexpr static basic_fixed_capacity_string /s Thanks
czw., 28 lis 2019 o 15:19 JeanHeyd Meneide via Boost
why was this library called fixed_string rather than static_string?
I like the name fixed because when I put it together with the static keyword it seems like less of a mess:
constexpr static static_vector... constexpr static fixed_vector...
I will say I like how the second one reads and static has the connotation of lifetime implications that I'm not sure static_vector or static_string actually do (they're not some sort of shared global-like storage for a thing). I hope both get changed to "fixed", as "static" is a nightmare of overloaded meaning, maybe with an alias "template <...> using fixed_vector = static_vector<...>". (Or we just come up with an even better short word, but I have no ideas for that!)
I agree that "static_" also has the potential to mislead.
Still, existing practice is important...
As pointed out in another thread, static_vector and fixed_string have taken a different design tradeoff regarding on what doing a `resize()` beyond `capacity()` means. static_string treats it as a precondition violation: https://www.boost.org/doc/libs/1_71_0/doc/html/boost/container/static_vector... fixed_string treats it as a correct (albeit rare) usage. (Although it is not documented clearly enough.) The architectural decision is: is it a user that is responsible for maintaining the size() below capacity() (the case of static_vector) or the library (the case of fixed_string). This decision warrants assigning a different prefix to fixed_string. Also, in the light of this, even name `fixed_capacity_string` would leave some ambiguity. Regards, &rzej;
Best, JeanHeyd
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On 28. Nov 2019, at 13:12, Vinnie Falco via Boost
wrote: On Thu, Nov 28, 2019 at 12:56 AM Andrzej Krzemienski via Boost
wrote: why was this library called fixed_string?
It was a mistake. It was originally static_string (it came from beast[1]) but someone suggested changing it and I listened. Oh well.
We already discussed the name a bit. At the danger of getting into bike-shedding (but names are important): Mateusz made the proposal "fixed_capacity_string", which is long but more precise than either static_string or fixed_string. I don't find the long name problematic, because I assume that this type wont often appear in interfaces, but rather somewhere deep in the implementation. Yet another idea: array_string Best regards, Hans
Le jeudi 28 novembre 2019 à 15:29 +0100, Hans Dembinski via Boost a écrit :
We already discussed the name a bit. At the danger of getting into bike-shedding (but names are important):
Mateusz made the proposal "fixed_capacity_string", which is long but more precise than either static_string or fixed_string.
It is. And i expect users who wish a shorter name to define fc_string as a non ambiguous alias.
I don't find the long name problematic, because I assume that this type wont often appear in interfaces, but rather somewhere deep in the implementation.
+1
Yet another idea:
array_string
This may mislead the reader (at least some non native english ones) into thinking it is an array of string. Array also misses the distinction between size / capacity, thus it does not look like a so good idea (there are places where a fixed_size_string could be useful). static_string has the advantage of consistency with static_vector. But static_vector is not a very good name itself. Regards, Julien
participants (5)
-
Andrzej Krzemienski
-
Hans Dembinski
-
JeanHeyd Meneide
-
Julien Blanc
-
Vinnie Falco