comp.lang.ada
 help / color / mirror / Atom feed
From: Preben Randhol <randhol+news@pvv.org>
Subject: Re: ML-like alternatives to out parameters for functions
Date: Tue, 18 Mar 2003 09:07:13 +0000 (UTC)
Date: 2003-03-18T09:07:13+00:00	[thread overview]
Message-ID: <slrnb7dodu.l3.randhol+news@kiuk0152.chembio.ntnu.no> (raw)
In-Reply-To: m3of49iqon.fsf@valhal.vikingnet

Mark Lorenzen wrote:
> There has lately been some discussions about Ada's missing
> capabilities for specifying out parameters for functions. Apparently
> this is a needed feature and an AI (AI-323) has been issued.
> 
> An out parameter can be used when the validity of the result of
> evaluating a function is not always well-defined. For example:
> 
> function Calculate (Argument : in AT; Result_Valid : out Boolean) return RT;
> 
> 
> Use of the function could be as:
> 
> Result := Calculate (Arg, Valid);
> if Valid then
>   .. do stuff with Result ..
> else
>   .. handle error ..
> end if;

Or you could do 

function Calculate (Argument : in AT; Result : out RT) return boolean;

Use of the function could be as:

if Calculate (Arg, Result) then
  .. do stuff with Result ..
else
  .. handle error ..
end if;

-- 
�Don't use C;  In my opinion,  C is a library programming language
 not an app programming language.�  - Owen Taylor (GTK+ developer)

Use Ada 95, a free language. More info at http://www.adapower.com/



  parent reply	other threads:[~2003-03-18  9:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-17 22:17 ML-like alternatives to out parameters for functions Mark Lorenzen
2003-03-17 21:47 ` Stephen Leake
2003-03-17 23:34   ` Mark Lorenzen
2003-03-18  3:54     ` John R. Strohm
2003-03-18  8:59     ` Preben Randhol
2003-03-18 21:09     ` tmoran
2003-03-18 17:04   ` Frank J. Lhota
2003-03-18 18:52     ` Mark Lorenzen
2003-03-18 19:16       ` Frank J. Lhota
2003-04-01  3:39         ` Robert I. Eachus
2003-04-01 14:51           ` Frank J. Lhota
2003-03-18  8:37 ` Dmitry A. Kazakov
2003-03-18  9:07 ` Preben Randhol [this message]
2003-03-19  7:31 ` Mark Biggar
  -- strict thread matches above, loose matches on Subject: below --
2003-04-02  0:23 Alexandre E. Kopilovitch
replies disabled

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