fixedstring: a @safe, @nogc string type

Moth postmaster at gmail.com
Wed Jan 12 19:55:41 UTC 2022


On Tuesday, 11 January 2022 at 17:55:28 UTC, H. S. Teoh wrote:
> [snip]
>
> One minor usability issue I found just glancing over the code: 
> many of your methods take char[] as argument. Generally, you 
> want const(char)[] instead, so that it will work with both 
> char[] and immutable(char)[]. No reason why you can't copy some 
> immutable chars into a FixedString, for example.

they should all already be `in char[]`? i've added a test to 
confirm it works with both `char[]` and `immutable(char)[]` and 
it compiles fine.

> [snip]
> Another issue is the way concatenation is implemented. Since 
> FixedStrings have compile-time size, this potentially means 
> every time you concatenate a string in your code you get 
> another instantiation of FixedString. This can lead to a LOT of 
> template bloat if you're not careful, which may quickly 
> outweigh any benefits you may have gained from not using the 
> built-in strings.

oh dear, that doesn't sound good. i hadn't considered that at 
all. i'm not sure how to even begin going about fixing that...



More information about the Digitalmars-d-announce mailing list