comp.lang.ada
 help / color / mirror / Atom feed
From: mockturtle <framefritti@gmail.com>
Subject: Re: abstract types and subprograms
Date: Tue, 20 May 2014 03:51:58 -0700 (PDT)
Date: 2014-05-20T03:51:58-07:00	[thread overview]
Message-ID: <a24c0cf4-3e60-48b9-983d-768e0640622e@googlegroups.com> (raw)
In-Reply-To: <llfad4$he$1@speranza.aioe.org>

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.

Riccardo


  reply	other threads:[~2014-05-20 10:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 10:22 abstract types and subprograms Victor Porton
2014-05-20 10:51 ` mockturtle [this message]
2014-05-20 11:45   ` Victor Porton
2014-05-20 16:27     ` Robert A Duff
2014-05-20 19:52       ` Dmitry A. Kazakov
2014-05-24 18:49         ` Robert A Duff
2014-05-24 19:41           ` Dmitry A. Kazakov
2014-05-20 11:55 ` Dmitry A. Kazakov
2014-05-20 12:28   ` Victor Porton
2014-05-20 14:11     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox