TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Mime-Version:
1.0
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To:
AdaWorks <[log in to unmask]>
Date:
Wed, 25 Nov 1998 15:22:02 -0500
Reply-To:
"Robert I. Eachus" <[log in to unmask]>
Subject:
From:
"Robert I. Eachus" <[log in to unmask]>
In-Reply-To:
<Pine.3.89.9811241400.A9446-0100000@netcom4>
Content-Type:
text/plain; charset="us-ascii"
Parts/Attachments:
text/plain (41 lines)
At 04:05 PM 11/24/98 -0800, AdaWorks wrote:
> Mr. Mize wants to implement a
>
>               object.method(parameter list)
>
>syntax.  This can be done by combining a generic with private package where
>the tagged type is in the private part of the package specification.  The
>actual object would be declared in the body.

   Exactly.

>Even though we can do this in Ada, it is probably a contrivance to accomodate
>some defensive notion of syntax rather than a model of good design or
coding >style.

   Slavish use of this idiom just for notational purity would be a bad idea.
But as your example shows, stacks are one of the cases in Ada where generic
package instances are often the best model for some object classes.  You can
use generic formal parameters and subprograms to allow type extension, and
generic formal package parameters can be used to pass any package from the
class as a parameter.

   Note that the "is <>;" default on formal generic subprograms is the one
instance of run-time polymorphism in Ada 83, although I would never
recommend using it just to obtain that effect. The run-time elaboration of
"is <>" is more of a pain for compiler vendors than anything else:
Generics are instantiated at run-time, and "is <>" matches the matching
subprogram statically enclosing the point of instantiation. (See RM
12.6(15).)  It is always possible to figure out the (static) parameter and
result profile to be matched for every textual generic instantiation at
compile time, and which delaration will correspond to it.  But it can be
the case that the actual subprogram created by that text to be called
cannot be determined until run-time.  In particular, the default parameter
values may not be known until the instantiation is elaborated.

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...

ATOM RSS1 RSS2