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 Path: border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: abstract types and subprograms Date: Tue, 20 May 2014 14:45:22 +0300 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: LRua1LhEwYx/r1KnMXeYtA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.12.4 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:186508 Date: 2014-05-20T14:45:22+03:00 List-Id: mockturtle wrote: > On Tuesday, May 20, 2014 12:22:30 PM UTC+2, Victor Porton wrote: > >> >> >> rdf-base.ads:20:04: function that returns abstract type must be abstract >> gnatmake: "/home/porton/Projects/librdf-ada/rdf-base.adb" compilation >> error >> >> By the philosophy of programming From_Handle should be non-abstract but >> return an abstract object, and From_Handle should be automatically >> overridden for descendants non-abstract objects. >> > > In my opinion, there is a contradiction: an abstract type is, by > definition, a type "without objects," in the sense that you cannot have a > value whose type is an abstract type. Therefore, you cannot have a > non-abstract function that returns an abstract type, since by calling it > you would create a value of an abstract type. > > Functions that return abstract types make sense. For example, they can be > used to "force" who derives from you abstract type to provide a > constructor for the derived type. I use them, for example, to implement > "plugins" in order to have a standard constructor for the derived type. > > I hope this can help you a bit. But does it make sense (philosophically, not accordingly the current specification) to use a function which returns an abstract type for a record extension aggregate? In my humble opinion, this use may be useful in a future Ada standard. -- Victor Porton - http://portonvictor.org