comp.lang.ada
 help / color / mirror / Atom feed
From: adam@irvine.com (Adam Beneschan)
Subject: Re: abstract sub programs overriding
Date: 8 Mar 2004 11:08:04 -0800
Date: 2004-03-08T11:08:04-08:00	[thread overview]
Message-ID: <b4682ab7.0403081108.7cf7436e@posting.google.com> (raw)
In-Reply-To: x7vu11096nc.fsf@smaug.pushface.org

Simon Wright <simon@pushface.org> wrote in message news:<x7vu11096nc.fsf@smaug.pushface.org>...
> Marius Amado Alves <amado.alves@netcabo.pt> writes:
> 
> > It's very simple, really: you can only call concrete, and of course 
> > available, operations.
> > 
> > In your program you had an abstract (not concrete) Generate (for a
> > 'root' type), and a concrete, but not available Generate (for a
> > derived type). The concrete Generate was not available (at the point
> > of the call) because it was declared in the private part of a
> > separate unit. So the first was available but was not concrete, the
> > second was not available, GNAT went for the only available one, and
> > naturally failed, mumbling whatever GNAT mumbles when it tries to
> > call an abstract operation.
> 
> I'm sure this explanation isn't right. The pointer concerned is to a
> classwide type, and the contract says that any actual Element_Record
> has a concrete (callable) Generate operation.
> 
> It would be easy to construct a program where Main had access to an
> Element (the classwide pointer) but not to Generator.Declarations
> (where the concrete type is defined).
> 
> I agree that putting it in the private part is perhaps misleading, but
> that doesn't mean it's wrong -- we need a lawyer!

Putting it in the private part doesn't matter, since a dispatching
call can still reach it (3.9.2(20), 7.6.1(3)).  In this case, the
abstract Generate that Type_Decl_Record inherits is overridden with a
nonabstract version (in the private part of Generator.Declarations);
this nonabstract version is then inherited by
Discrete_Type_Decl_Record, and later by Enumerate_Type_Decl_Record. 
This last inherited subprogram is the one that should be called when a
dispatching call is made to Generate on an object of type
Enumerate_Type_Decl_Record.

In fact, I think the whole discussion about abstract vs. concrete
subprograms is barking up the wrong tree.  As far as I know, there
should never be a runtime error for an attempt to call an abstract
subprogram.  The language rules ensure that this can never happen,
i.e. that whenever you call a subprogram (either directly or via
dispatching), that subprogram will be concrete (as opposed to C++,
which I believe does not guarantee this).  This is accomplished by
disallowing objects of an abstract type and direct calls to an
abstract subprogram, and, most importantly, by disallowing primitive
abstract subprograms of a nonabstract tagged type, and by requiring
that abstract subprograms be overridden when a derived type is
nonabstract.

I would expect the "access check" error to refer to an accessibility
level problem (although I can't speak to what other errors might cause
GNAT to say "access check").  Since all the access types in this code
are library level (none is declared inside a subprogram), it does seem
quite weird that this error would be showing up.

                                  -- Adam



  parent reply	other threads:[~2004-03-08 19:08 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-02 19:01 abstract sub programs overriding Evangelista Sami
2004-03-03  1:43 ` Stephen Leake
2004-03-05 15:02   ` Evangelista Sami
2004-03-05 16:15     ` Marius Amado Alves
2004-03-08 18:54       ` Adam Beneschan
2004-03-08 23:42         ` Marius Amado Alves
2004-03-05 16:26     ` Marius Amado Alves
2004-03-06  9:31       ` Simon Wright
2004-03-06 15:18         ` Evangelista Sami
2004-03-06 19:09           ` Marius Amado Alves
2004-03-07 12:35             ` Simon Wright
2004-03-07 13:39               ` Marius Amado Alves
2004-03-08 19:08               ` Adam Beneschan [this message]
2004-03-08 20:03                 ` Hyman Rosen
2004-03-09  8:51                   ` Dmitry A. Kazakov
2004-03-09 13:34                     ` Hyman Rosen
2004-03-09 14:49                       ` Dmitry A. Kazakov
2004-03-09 15:14                         ` Hyman Rosen
2004-03-09 15:56                           ` Dmitry A. Kazakov
2004-03-09 16:32                             ` Hyman Rosen
2004-03-10  9:32                               ` Dmitry A. Kazakov
2004-03-10 13:08                                 ` Hyman Rosen
2004-03-10 14:58                                   ` Robert I. Eachus
2004-03-10 16:00                                     ` Hyman Rosen
2004-03-10 18:07                                       ` Robert I. Eachus
2004-03-10 20:04                                         ` Hyman Rosen
2004-03-11  2:43                                           ` Robert I. Eachus
2004-03-11 13:55                                             ` Hyman Rosen
2004-03-12 23:02                                               ` Robert I. Eachus
2004-03-14 21:33                                                 ` Hyman Rosen
2004-03-15  5:59                                                   ` Robert I. Eachus
2004-03-15 14:39                                                     ` Hyman Rosen
2004-03-16 16:16                                                       ` Robert I. Eachus
2004-03-16 16:51                                                         ` Hyman Rosen
2004-03-16 19:54                                                         ` Hyman Rosen
2004-03-16 23:16                                                           ` Randy Brukardt
2004-03-17  1:54                                                           ` Robert I. Eachus
2004-03-16 23:14                                                         ` Randy Brukardt
2004-03-17  2:43                                                           ` Robert I. Eachus
2004-03-17 17:40                                                             ` Randy Brukardt
2004-03-18  2:39                                                               ` Robert I. Eachus
2004-03-18  5:57                                                                 ` Randy Brukardt
2004-03-18 15:03                                                                   ` Hyman Rosen
2004-03-18 20:32                                                                     ` Randy Brukardt
2004-03-19  3:59                                                                       ` Hyman Rosen
2004-03-19 19:37                                                                         ` Randy Brukardt
2004-03-16  6:00                                               ` Randy Brukardt
2004-03-11 10:09                                   ` Dmitry A. Kazakov
2004-03-11 14:10                                     ` Hyman Rosen
2004-03-11 14:59                                       ` Dmitry A. Kazakov
2004-03-11 15:40                                         ` Hyman Rosen
2004-03-11 16:28                                           ` Dmitry A. Kazakov
2004-03-11 17:26                                             ` Hyman Rosen
2004-03-12  8:53                                               ` Dmitry A. Kazakov
2004-03-12 13:09                                                 ` Hyman Rosen
2004-03-12 14:00                                                   ` Dmitry A. Kazakov
2004-03-12 14:56                                                     ` Hyman Rosen
2004-03-12 18:19                                                       ` Dmitry A. Kazakov
2004-03-12 18:34                                                         ` Hyman Rosen
2004-03-12 20:05                                                           ` Georg Bauhaus
2004-03-13 10:12                                                           ` Dmitry A. Kazakov
2004-03-12 18:07                                               ` Robert I. Eachus
2004-03-10 15:51                 ` Evangelista Sami
2004-03-11  1:38                   ` Dan Eilers
2004-03-06 23:20     ` Dan Eilers
2004-03-03 12:00 ` Marius Amado Alves
2004-03-13  7:51 ` Simon Wright
replies disabled

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