:: Re: [DNG] Ada strings
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Didier Kryn
Fecha:  
A: dng
Asunto: Re: [DNG] Ada strings
Le 07/10/2024 à 01:49, Steve Litt a écrit :
> Hi all,
>
> I've studied Ada the past couple days, and I gotta tell you, Ada
> strings are very murky. From what I've learned, Ada has three kinds of
> strings:
>
> Fixed strings
> Bounded strings
> Unbounded strings
>
> Fixed strings are pretty simple but you can't reassign a different
> string to a fixed string unless the new string has identical length.
>
> Unbounded strings require lots of conversions to use, and they're
> pretty hairy.
>
> My investigation of bounded strings tells me that every single guidance
> and example of bounded strings on the Internet is wrong.
>
> So far I've found dealing with strings in Ada to be nasty.
>
> I'm using gnatmake 13.2.0 . I have no idea if it's Ada 2005, 2012, or
> 2022. I'm guessing that different versions break things from other
> versions.
>

    AFAIR, when dealing with variable length strings, I've always used
bounded strings. In essence it is like in C allocating a buffer large
enough; then you get all convenient procedures and functions, and don't
need to worry about null termination. unbounded strings are for when you
may have strings of unprevisible length or memory constraints.

--     Didier