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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.138.81 with SMTP id qo17mr6474999pab.26.1466814142472; Fri, 24 Jun 2016 17:22:22 -0700 (PDT) X-Received: by 10.157.41.105 with SMTP id d96mr82712otb.19.1466728735803; Thu, 23 Jun 2016 17:38:55 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!news.glorb.com!jk6no787542igb.0!news-out.google.com!i62ni1987ith.0!nntp.google.com!jk6no787504igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 23 Jun 2016 17:38:55 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8202:8510:5985:2c17:9409:aa9c; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8202:8510:5985:2c17:9409:aa9c References: <58b78af5-28d8-4029-8804-598b2b63013c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: RFC: Prototype for a user threading library in Ada From: rieachus@comcast.net Injection-Date: Sat, 25 Jun 2016 00:22:22 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:30914 Date: 2016-06-23T17:38:55-07:00 List-Id: I don't get it. If this is your "motivation": > The motivation is a two-liner. Let you have some consumer of data:=20 > > procedure Write (Buffer : String; Last : out Integer);=20 > > It may take less than the whole string when called, but will take more=20 > data later. So, the parameter Last. Now you want to write a program in a= =20 > *normal* way:=20 > > Write ("This");=20 > Write ("That");=20 > > That's it.=20 You may want to make your Last parameter in or in out, but that's a detail. The common Ada idiom is: procedure Write (S: in String) is Blanks: constant Buffer :=3D (others :=3D ' '); -- I assume that their are constant size buffers around somewhere we are -- matching. SS: String(1..S'Length) :=3D S; begin Write(S & Blanks(Buffer(SS'Length+1..Blanks'Last), SS'Length); end Write; -- SS is just belt and suspenders in case S has unusual bounds.=20 Put this in the right place, and your calls above will call your Write proc= edure. Of course, most Ada IO doesn't require padding. (That is what Uncon= strained_Strings are for.) But if you have a low-level routine that needs, = padding, for example a protected object that has a procedure with a fixed b= uffer size? No big deal. And don't worry about the constant Blanks. Assuming it is a reasonable siz= e, your compiler should put it in the executable somewhere. (If it doesn't= , move it to a library package.) Little routines like this are what makes Ada.Text_IO comfortable, if you re= ally have to use it.