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.129.82.17 with SMTP id g17mr55271438ywb.14.1435186332465; Wed, 24 Jun 2015 15:52:12 -0700 (PDT) X-Received: by 10.140.38.180 with SMTP id t49mr490823qgt.9.1435186332442; Wed, 24 Jun 2015 15:52:12 -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!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!q107no3149263qgd.0!news-out.google.com!4ni2669qgh.1!nntp.google.com!z60no3147451qgd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 24 Jun 2015 15:52:12 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.99.95.58; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 83.99.95.58 References: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> <17436268-aceb-461f-bdcf-eee8436cd0e6@googlegroups.com> <86y4jaqzdx.fsf@stephe-leake.org> <86oak5qulb.fsf@stephe-leake.org> <78882aed-4063-409b-a92e-6025c3097a52@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4f347eab-79ac-4a70-900b-0b81eebcc583@googlegroups.com> Subject: Re: What do you think about this? From: Laurent Injection-Date: Wed, 24 Jun 2015 22:52:12 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 3966 X-Received-Body-CRC: 3280676717 Xref: news.eternal-september.org comp.lang.ada:26466 Date: 2015-06-24T15:52:12-07:00 List-Id: On Thursday, 25 June 2015 00:30:32 UTC+2, Jeffrey R. Carter wrote: > > So Example_A : Bound_String := "123" so the Example_A'Length = 3 > > Example_B: Bound_string:= "Only a test" Example_B'Length = 11 > > Note your inconsistent use of whitespace here. Example_A has spaces on both > sides of ':' and ":="; Example_B on on the right. GPS would have corrected that after typing enter. This is unfortunately not GPS. > type String is array (Positive range <>) of Character; > > It's an unconstrained type just like any other unconstrained type. Some > languages have strings that are special, and users cannot declare a type like > them, but in Ada they are just the same as any other array. Your confusion is > likely from expecting String to have special properties; if you can stop > thinking that way then String will probably make more sense. > > Of course, String objects have to be constrained: > > S1 : String (7 .. 9); > S2 : String := "Only a test"; > > S1 is explicitly constrained, while S2 gets the constraints of its > initialization value (1 .. 11). Once constrained, the bounds of String object > cannot change. You can change the contents, but not the length, so you can say > > S2 (1 .. 4) := "Just"; -- S2 is now "Just a test" > > because the array value on the right has the same length as the array object on > the left (4). You can't say > > S2 := "123"; > > because the array value on the right has a length of 3, which is not the same as > the object on the left (11); > > In your case you have a function sort of like > > function F return Bounded_String is > R : Bounded_String; > begin -- F > R := +(A & B & C); > > return R; > end F; > > where A, B, and C are of type String. You could eliminate R and just say > > return +(A & B & C); > > You use this in a call to a file operation such as Create: > > Create (Name => +F, ...); > > The parameter Name is of type String. What you could have done is > > function F return String is > -- No declarations > begin -- F > return A & B & C; > end F; > > and then > > Create (Name => F, ...); > > I hope that helps make things clearer. > > -- > Jeff Carter > "Well, a gala day is enough for me. I don't think > I can handle any more." > Duck Soup > 93 Has to wait until this evening. I will only have 4 hrs of sleep. Great!