comp.lang.ada
 help / color / mirror / Atom feed
From: Richard D Riehle <laoXhai@ix.netcom.com>
Subject: Re: 'constant functions' and access constant params (was Re: Array of Variant Records Question...)
Date: 1999/09/27
Date: 1999-09-27T12:36:43-05:00	[thread overview]
Message-ID: <7so9vb$59b@dfw-ixnews19.ix.netcom.com> (raw)
In-Reply-To: 37e994c0@news1.prserv.net

In article <37e994c0@news1.prserv.net>,
	"Matthew Heaney" <matthew_heaney@acm.org> wrote:


>For private types, the supplier is (or should be) free to make internal
>modifications, to the extent that the postcondition is satisfied.  This is
>where we disagree.

We agree, then, that a designer should be allowed to design a
contract that declares (X : access constant T) as a mode for a 
non-private type. Interesting that we both came to this notion
independently and found ourselves arguing about it.  I have, 
before this little discussion, encountered others in the Ada 
community who have also come to this idea on their own.  

>Agree for non-private data.  Disagree for private data.

Now we are focusing on the precise area of disagreement.  Once again,
we are not so far apart.  If we are to agree that the syntax, 

    function F(X : access constant T) return R;

or something like it (I am not as concerned with the syntax as the
semantics), then it would make sense to extend that capability to
all types, private and non-private.  The designer has the ability 
to overload an operation with a new primitive, though not ability to
override it.  This does introduce a complication in the overloading
rules that requires a compiler to check one additional mode level of
the parameter profile.  However, that is true with both private and
non-private types.

In my earlier example, repeated below, 

>>   package Abstract_Level is
>>     type Abstract_Declaration is abstract tagged private;
>>     procedure X ( . . .) is abstract;
>>     procedure Y ( . . .) is abstract;
>>     function  F (A : access constant Abstract_Declaration) 
                             return some-type
>>                           is abstract;
>>  private
>>    type Abstract_Declaration is abstract tagged private;
>>  end Abstract_Level;

The class designer is explicitly declaring that overriding of the 
function F prohibits modification of the data components of
Abstract_Declaration. If it becomes useful to introduce a new 
function later with different properties, no problem.  

Returning to the syntax issue for a moment, I am still not convinced 
that, in the absence of explicit pre-, post-, and invariant conditions, 
having the ability to declare a function as constant would not be a
useful feature.  In this case, the constant function would behave 
just like a protected function.  Although you, along with many others,
do not like this syntax,

          constant function F ( ... ) return ...

it would serve the purpose nicely.  Such functions would be only 
useful as queries on the state of data.  I realize that
this notion foments another storm of protest and indignation. 

Richard Riehle
richard@adaworks.com
http://www.adaworks.com






  parent reply	other threads:[~1999-09-27  0:00 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-08  0:00 Array of Variant Records Question Bruce Detter
1999-09-08  0:00 ` Ted Dennison
1999-09-08  0:00 ` Matthew Heaney
1999-09-08  0:00   ` Mike Silva
1999-09-08  0:00     ` Matthew Heaney
1999-09-09  0:00       ` Robert Dewar
1999-09-09  0:00         ` Matthew Heaney
1999-09-09  0:00           ` Matthew Heaney
1999-09-09  0:00             ` Robert Dewar
1999-09-09  0:00             ` Mark Lundquist
1999-09-09  0:00           ` Robert Dewar
1999-09-09  0:00             ` Brian Rogoff
1999-09-13  0:00               ` Matthew Heaney
1999-09-13  0:00                 ` Robert A Duff
1999-09-13  0:00                   ` Matthew Heaney
1999-09-13  0:00                 ` Brian Rogoff
1999-09-14  0:00                   ` Robert Dewar
1999-09-14  0:00                     ` Brian Rogoff
1999-09-14  0:00                   ` Robert Dewar
1999-09-09  0:00             ` Matthew Heaney
1999-09-10  0:00               ` Mark Lundquist
1999-09-10  0:00                 ` Matthew Heaney
1999-09-11  0:00                 ` Robert Dewar
1999-09-10  0:00               ` Robert Dewar
1999-09-10  0:00                 ` Mark Lundquist
1999-09-10  0:00                   ` Matthew Heaney
1999-09-11  0:00                     ` Jean-Pierre Rosen
1999-09-14  0:00                     ` "cast away const" (was Re: Array of Variant Records Question...) Mark Lundquist
     [not found]                     ` <wccd7viiv59.fsf@world.std.com>
     [not found]                       ` <7rrmqd$l89@drn.newsguy.com>
     [not found]                         ` <wcciu59n2uf.fsf@world.std.com>
1999-09-22  0:00                           ` Array of Variant Records Question Robert I. Eachus
1999-09-23  0:00                             ` Robert Dewar
1999-09-23  0:00                               ` Robert I. Eachus
1999-09-22  0:00                       ` Robert I. Eachus
1999-09-11  0:00               ` Richard D Riehle
1999-09-13  0:00                 ` Hyman Rosen
1999-09-14  0:00                 ` Mark Lundquist
     [not found]                   ` <7roohh$s6r@dfw-ixnews7.ix.netcom.com>
     [not found]                     ` <37e01168@news1.prserv.net>
     [not found]                       ` <7rp86o$c6h@dfw-ixnews3.ix.netcom.com>
     [not found]                         ` <37E18CC6.C8D431B@rational.com>
     [not found]                           ` <7rs8bn$s6@dfw-ixnews4.ix.netcom.com>
     [not found]                             ` <37e2e58c@news1.prserv.net>
1999-09-22  0:00                               ` 'constant functions' and access constant params (was Re: Array of Variant Records Question...) Richard D Riehle
1999-09-22  0:00                                 ` Mark Lundquist
1999-09-22  0:00                                   ` Mark Lundquist
1999-09-22  0:00                                 ` Matthew Heaney
1999-09-22  0:00                                   ` Richard D Riehle
1999-09-22  0:00                                     ` Matthew Heaney
1999-09-23  0:00                                       ` Vincent Marciante
1999-09-23  0:00                                         ` Matthew Heaney
1999-09-24  0:00                                       ` Robert A Duff
1999-09-25  0:00                                         ` Matthew Heaney
1999-09-27  0:00                                       ` Richard D Riehle
1999-09-27  0:00                                       ` Richard D Riehle [this message]
1999-09-27  0:00                                         ` David Kristola
1999-09-22  0:00                                     ` Matthew Heaney
1999-09-23  0:00                                     ` Robert Dewar
1999-09-27  0:00                                       ` Richard D Riehle
1999-09-28  0:00                                         ` Robert Dewar
1999-09-28  0:00                                           ` "Competence" (was: 'constant functions' and access constant params) Ted Dennison
1999-09-28  0:00                                             ` Robert Dewar
1999-09-28  0:00                                         ` 'constant functions' and access constant params (was Re: Array of Variant Records Question...) Robert Dewar
1999-09-28  0:00                                           ` Richard D Riehle
1999-09-29  0:00                                             ` Robert Dewar
1999-09-29  0:00                                             ` Robert A Duff
     [not found]                             ` <wccemfxn15s.fsf@world.std.com>
1999-09-22  0:00                               ` Richard D Riehle
1999-09-10  0:00             ` Proposed Ada features " Mark Lundquist
1999-09-10  0:00               ` Matthew Heaney
1999-09-10  0:00                 ` tmoran
1999-09-09  0:00     ` Array of Variant Records Question Nick Roberts
1999-09-09  0:00       ` Tucker Taft
1999-09-10  0:00         ` Nick Roberts
1999-09-09  0:00       ` Robert Dewar
1999-09-08  0:00 ` Thank you Bruce Detter
1999-09-08  0:00   ` Martin C. Carlisle
1999-09-08  0:00 ` Array of Variant Records Question Martin C. Carlisle
replies disabled

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