comp.lang.ada
 help / color / mirror / Atom feed
From: aio!dnsurber@eos.arc.nasa.gov  (Douglas N. Surber)
Subject: Re: Generic Instantiation as Subprogram Body? (Clarification)
Date: 19 Oct 92 13:23:26 GMT	[thread overview]
Message-ID: <dnsurber.719501006@node_26400> (raw)

In <1992Oct16.225115.11359@inmet.camb.inmet.com> stt@spock.camb.inmet.com (Tuck
er Taft) writes:

>For readability and consistency reasons the body may not 
>be an instantiation itself, since an instantiation
>does not repeat the parameter profile, so correlating it
>with the specification that it is implementing
>is a potentially error-prone process in the presence of overloading.

I guess I don't see why this is error prone, at least for the compiler.  It
certainly might be error prone for the human reader.  Given the name of the
generic subprogram and the generic actual parameters, the parameter profile
of the instance is known.  Admittedly the names of the formals could be
different, but the names of the formals are not used in overload resolution.
Thus it seems to me that the compiler should have no problem resolving any
overloading.  Of course I could have easily overlooked something.

It would certainly be error prone for the programmer.  But then so would
having to maintain two declarative items, the instantiation and the rename,
to properly implement a subprogram body.  This does seem arbitrary and it
more or less requires a kludge everytime a instantiation is used as a
subprogram body, but I guess it works and it is upward compatible.

I think I might prefer something like the following, although it is not
upward compatible.

Instead of having generic_instantiation as a possible alternative of
declarative_item, have new generic_subprogram_name [generic_actual_part]; as
an alternative for subprogram_body.  Ditto for functions and packages.  This
would eliminate the generic_instantiation as a non-terminal.  This seems
more natural to me.  As a reader of a program, I am not interested in the
fact that some package and some function are related in that they are both
generic instantiations, that doesn't tell me anything.  But I am interested
to see which method is used to specify a procedure, a complete body, an
instantiation, or a rename. (I would suggest the same sort of change for
renames.)  Each of these is a mechanism for specifying what happens when a
subprogram is invoked, at least this is how I think about it.

I don't have real strong feelings about this.  I think the current 9X
proposal is kludgy, but it is workable and upward compatible.  I would
prefer a cleaner solution, such as what I outlined above, but there would be
compatibility issues.  I'm glad I don't have to make the final decision.

Douglas Surber
Lockheed
Houston, TX

             reply	other threads:[~1992-10-19 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-10-19 13:23 Douglas N. Surber [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-10-16 22:51 Generic Instantiation as Subprogram Body? (Clarification) sun-barr!cs.utexas.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!inmet
1992-10-14 20:30 Douglas N. Surber
replies disabled

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