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.43.70.132 with SMTP id yg4mr8633594icb.30.1406764980147; Wed, 30 Jul 2014 17:03:00 -0700 (PDT) X-Received: by 10.50.153.77 with SMTP id ve13mr226921igb.16.1406764980008; Wed, 30 Jul 2014 17:03:00 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.ripco.com!news.glorb.com!h18no6729480igc.0!news-out.google.com!px9ni1igc.0!nntp.google.com!h18no6729478igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 30 Jul 2014 17:02:59 -0700 (PDT) In-Reply-To: <166aaec5-5e9c-40e0-9b07-9b9c7d5f7f33@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <166aaec5-5e9c-40e0-9b07-9b9c7d5f7f33@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Quick question regarding limited type return syntax From: Adam Beneschan Injection-Date: Thu, 31 Jul 2014 00:03:00 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:21358 Date: 2014-07-30T17:02:59-07:00 List-Id: On Wednesday, July 30, 2014 4:51:10 PM UTC-7, NiGHTS wrote: > I am designing a package which features a "Create" function that returns = a newly instantiated "Object" which is a discriminated limited type. The co= de compiles and operates correctly but gives me a warning that "New_Object"= is not used. See below (ellipses represent omitted code): > package Test is > type Object (Parameters : access String) is tagged limited private; > function Create (...) return Object; > ... > private > type Object (Parameters : access String) is tagged limited > record > Database : PQ.Database (Parameters); > ... > end record; > ... > end Test; >=20 > package body Test is > function Create(...) return Object is > ... > begin > return New_Object : Object (Connection_String'Access) do=20 > null; > end return; > end; > ... > end Test; > To remove this warning I've tried this: >=20 > return Object (Connection_String'Access) do null; end return; >=20 > and it gives an error about expecting a ';'. I've also tried this: >=20 >=20 >=20 > return Object (Connection_String'Access); >=20 > Compiler tells me "argument of conversion cannot be access".=20 >=20 > I have tried other syntax variants but all produce errors. My goal here i= s to avoid using "new" which is why I am trying to return the instance in t= his way. >=20 > How can I rewrite this code so that I won't get any errors or warnings? What is a PQ.Database? =20 I've tried this with various dummy types for the Database, and when I get a= warning it's that the object is "read but never assigned". Is that the wa= rning you're getting? That's different from a warning that says it's never= used. It appears to me that if this field were assigned in New_Object, or if Data= base had an initial value in the record or if all components of Database ha= d initial values, you wouldn't get the warning. -- Adam