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.157.38.238 with SMTP id i43mr2894080otd.5.1458762699765; Wed, 23 Mar 2016 12:51:39 -0700 (PDT) X-Received: by 10.182.113.198 with SMTP id ja6mr55656obb.0.1458762699717; Wed, 23 Mar 2016 12:51:39 -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.mixmin.net!news.glorb.com!y89no9061522qge.0!news-out.google.com!h70ni734qge.0!nntp.google.com!w104no8406648qge.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 23 Mar 2016 12:51:39 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=149.32.224.36; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 149.32.224.36 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2b215924-fdb7-4f58-b496-018ab837feec@googlegroups.com> Subject: Re: Need some help in Ada From: Anh Vo Injection-Date: Wed, 23 Mar 2016 19:51:39 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:29862 Date: 2016-03-23T12:51:39-07:00 List-Id: On Wednesday, March 23, 2016 at 12:29:05 PM UTC-7, danif...@gmail.com wrote= : > Hello there! >=20 > I'm a student, and i've got my 1st home project in Ada. I need to impleme= nt a J_String package with a lot of functions etc, but i have problems at t= he start. The specification asks me to "implement J_String type as an opaqu= e discriminant record type. For the inner representation of the string use = the Standard String type. The discriminant determines the size of the strin= g, which is contained in the J_String type." >=20 > My .ads at the moment: >=20 > package J_String_Pkg is > type J_String(Size: Natural) is private; > private > type J_String(Size: Natural) is record > Components: String(Natural Range 0..Natural'Last); > end record; > end J_String_Pkg; >=20 > I don't know if the above is good, but the main reason i'm asking help is= the following methods: > function Create(Str : String) return J_String; > --Creates a J_String from a String > function Value_Of(S : J_String) return String; > --Returns the content of S in String type > function Is_Empty(S : J_String) return Boolean;=20 > -- Returns true if, and only if, length() is 0. >=20 > I think i can do the other 20+ methods, but i can't figure out how to mak= e my J_String type to be able to create empty strings. Thanks for every hel= p! Empty string means string length is 0. That means upper string index is les= s than lower string index. For example, an empty predefined string looks li= ke this. Empty_String : String (1 .. 0) :=3D ""; By the way, now you can see why the record field Components is not correct.= =20 Anh Vo