From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,45b47ecb995e7a3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-14 06:35:03 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!psinet-eu-nl!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Ada Idioms Progress Preview Date: Tue, 14 Aug 2001 09:22:23 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9lb8mh$9am$1@nh.pace.co.uk> References: <3B6F1B2F.4FC3C833@gsde.hou.us.ray.com> <5ee5b646.0108071819.6e84e33d@posting.google.com> <3_Xc7.45$NM5.84779@news.pacbell.net> NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 997795345 9558 136.170.200.133 (14 Aug 2001 13:22:25 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 14 Aug 2001 13:22:25 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:11912 Date: 2001-08-14T13:22:25+00:00 List-Id: This works nicely so long as you are doing one of two things (again, by convention.) If you are always allocating your strings off the stack after deciding how much space you need by entering a new scope or you are always allocating your strings off the heap with the "new" operator. Both cases allow you to write string handling code that takes advantage of 'First, 'Last, 'Length and so on. However, this is not always convenient or simple. Certainly, understanding the idioms necessary to do it is maybe just a bit beyond the beginner. (Hey, there's a topic for the Idiom Guys!) Also, it is not something that is assumed by all of the language supplied services. (Text_IO, being a problem in this area. Suppose that a Get_Line were to return an access to a string instead of putting characters into your own string and giving you a length? That would have its own pitfalls, but it would allow you to structure everything else using 'First 'Last & 'Length.) Maybe Ada0x should attempt to establish some convention here? Ahhhhhh.... Skip it! We've got Unbounded strings - just use them!. :-) MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/ "Ted Dennison" wrote in message news:zVXd7.109$2u.23585@www.newsranger.com... > It frees you from that problem in *some* cases. I find that most of the time I > don't change the string, so I can declare it perfectly sized. When you do that, > you are not storing the length explicitly, but rather implicitly in the array > bounds. As others have mentioned, you also don't have to iterate through every > valid data element to derive this piece of implicit information like you do with > C. Thus perfectly-sized Ada strings give you the best of both worlds. > > Unfortunately, the most notable exception to this is in reading data from > Text_IO, which is also one of the first things a newbie will want to do with Ada > strings. :-( >