comp.lang.ada
 help / color / mirror / Atom feed
From: marciant@earthlink.net
Subject: Re: A function that cannot be called?
Date: Fri, 19 Oct 2018 16:28:11 -0700 (PDT)
Date: 2018-10-19T16:28:11-07:00	[thread overview]
Message-ID: <63024b3f-d176-4b64-a861-a28d1dfca1f1@googlegroups.com> (raw)
In-Reply-To: <1a143584-e575-47b2-ab99-f5b6c3382add@googlegroups.com>

On Friday, October 19, 2018 at 4:25:53 PM UTC-4, Shark8 wrote:
<snip>
> > 
> > Before Ada 95 or Ada 2005 it would have been a package
> > spec that had the following (with P1,P2,etc. being valid types): 
> > 
> > type Not_Objects_Just_for_Parameters is limited private;
> > function Return_A_Corresponding_Value(p1:t1;p2:t2;etc...)
> >   return Not_Objects_Just_for_Parameters;
> > procedrure Force_Call_Of_Function_1
> >           (Function_Call:Not_Objects_Just_for_Parameters;
> >            Other_Param3:p3;etc...);
> > procedrure Force_Call_Of_Function_2
> >           (Function_Call:Not_Objects_Just_for_Parameters;
> >            Other_Param4:p4;etc...);
> > 
> > I miss that way of forcing/ensuring new execution of some
> > code as a prerequisite of use of a subprogram. ;-(
> > Being able to hang on to the result of such a function
> > by using renames wrecks this usage.
> 
> Isn't there a similar effect that can be had via
> 
>   Type Just_For_Parameters(<>) is limited private;
>   Function Get_Param return Just_For_Parameters;
>   --...
> PRIVATE
>   Type Stub_Record is null record;
>   Type Just_For_Parameters is not null access Stub_Record
>     with Size => 0;
>   --...

> Or am I misunderstanding what you're getting at? (Quite possible as I've never had occasion to use Size 0 "access"-types.)

I think you are but am not sure. I was focussing of the type from the point of view of an outside user of the package and the Size code that you presented would only affect use in the package body or child units.

The big problem that messed things up for me was now being able to something like this:

...

declare
  ob : Limitted_Private_Type renames Function_Call(...);
begin
  Proc1(ob);
  Proc2(ob);
  Proc3(ob);
  ...

all procs getting the same value/object (Function_Call is
evaluated only once.)

Oh! Maybe the bothersome thing now is that functions can no longer
return a limited result. (Not sure if that was a correct statement.)

Anyway, although I find that do not remember the exact details for now, but I do remember for sure that it once was possible to declare a visible type in a package spec that could not be used by an outside user as the type of a variable or constant and the only things that could be passed to any subprograms in the type's package were a call of a function from that package that returned that type (and maybe also deferred constants from that same package). Wow! It _has_ been a long ride.  :-)  :-/


   


      reply	other threads:[~2018-10-19 23:28 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 12:14 A function that cannot be called? G.B.
2018-10-18 15:33 ` Stefan.Lucks
2018-10-18 20:21   ` G.B.
2018-10-18 20:57     ` Niklas Holsti
2018-10-19  7:15     ` Dmitry A. Kazakov
2018-10-19 13:55       ` G.B.
2018-10-19 15:31         ` Dmitry A. Kazakov
2018-10-18 17:03 ` AdaMagica
2018-10-18 19:36   ` G.B.
2018-10-18 21:30     ` Randy Brukardt
2018-10-19 14:00       ` G.B.
2018-10-19 15:39         ` Dmitry A. Kazakov
2018-10-20  1:34         ` Randy Brukardt
2018-10-20  9:14           ` G.B.
2018-10-20 11:13             ` Simon Wright
2018-10-20 14:11               ` Dmitry A. Kazakov
2018-10-21  9:25                 ` G.B.
2018-10-21  9:07               ` G.B.
2018-10-21  9:51                 ` Dmitry A. Kazakov
2018-10-21 10:57                 ` Niklas Holsti
2018-10-21 18:00                 ` Simon Wright
2018-10-19  8:48 ` AdaMagica
2018-10-19 11:15   ` G.B.
2018-10-19 17:06     ` AdaMagica
2018-10-19 19:57       ` G.B.
2018-10-19 22:06         ` Jere
2018-10-21 10:14           ` G.B.
2018-10-21 11:30             ` Egil H H
2018-10-23 11:45               ` G.B.
2018-10-23 14:35                 ` Jere
2018-10-23 14:57                   ` Dmitry A. Kazakov
2018-10-23 17:49                     ` G.B.
2018-10-23 19:25                       ` Dmitry A. Kazakov
2018-10-24  7:35                         ` G.B.
2018-10-24  8:14                           ` Dmitry A. Kazakov
2018-10-19 18:19 ` marciant
2018-10-19 18:22   ` marciant
2018-10-20  1:36     ` Randy Brukardt
2018-10-20  2:54       ` marciant
2018-10-19 20:25   ` Shark8
2018-10-19 23:28     ` marciant [this message]
replies disabled

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