Re: why only in-parameters in functions

From: Alexander E. Kopilovich (aek_at_VB1162.spb.edu)
Date: 09/29/04


Date: Wed, 29 Sep 2004 20:55:05 +0400 (MSD)
To: comp.lang.ada@ada-france.org

Rick Santa-Cruz wrote:

> I know that it is only allowed to use in-parameters with functions. But I
> can't figure out what is the idea behind this. Why did the Ada-Team only
> allow in-parameter when using functions?

There were so many discussions on this matter, at various levels, and so manu
arguments pro and contra were expressed that perhaps there should be FAQ for
this topic alone.

In short, for many years Ada community and ARG (which can be seen as Ada
design team) were (and still are) divided about this matter.

In practice, where you really need in-parameters for a function you may either
use a procedure that returns value (if you use GNAT compiler) or you may use
the construct, presented here in c.l.a by Robert I. Eachus (see his message
in comp.lang.ada from 2003-07-15 with Subject: Re: What evil would happen?)

----------------------------------------------------------------------------

function Random(Gen: in Generator) return ...
   Local: Generator;
   for Local'Address use Gen'Address;
begin
   ...
end Random;

----------------------------------------------------------------------------

Alexander Kopilovich aek@vib.usr.pu.ru
Saint-Petersburg
Russia