3 ms·
I'm really not fond of string handling in Ada, but I can't imagine seriously arguing that C-strings are better. Ada strings can be a pain to work with - but th
by foerbert 6y ago
I'm really not fond of string handling in Ada, but I can't imagine seriously arguing that C-strings are better.
Ada strings can be a pain to work with - but that's basically just my problem. And I haven't found it to be all that terrible, actually. Use unbounded strings. Don't mix fully-specified string types. There's even some fairly common styles for shorthands, like the unary '+' for unbounded conversions.
It's not great, but it's pretty fine. I don't do so much string manipulation that it's a huge deal. Most all problems will be caught at compile time. Things like the OP are pretty much all taken care of by simply not mixing fully specified string types.
And even if you do do it, the worst that'll happen is an exception. That's it. Meanwhile, try misusing a C-string. If you don't get to enjoy trying to track down that problem from all the strange problems it causes, somebody else will be glad to gleefully use it to exploit your program.
Ada strings are annoying to you, but they won't cause massive problems - either for you or your users. You cannot say the same for C-strings. I'll take a bit of easily solved bother over trying to debug buffer overruns or massive security problems.