comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com (Ted Dennison)
Subject: Re: Out parameters in a function
Date: 15 Apr 2002 08:09:24 -0700
Date: 2002-04-15T15:09:25+00:00	[thread overview]
Message-ID: <4519e058.0204150709.55c94dfb@posting.google.com> (raw)
In-Reply-To: a9chqr$23e76$1@ID-107015.news.dfncis.de

"Nazgul" <darkelf@aim.homelinux.com> wrote in message news:<a9chqr$23e76$1@ID-107015.news.dfncis.de>...
> function ReadChar(f: File; c: out character) return boolean;
> 
> The function must return a boolean, so the only way to read the character is
> via the 'c' parameter. In other context, I use
...
> Is there any way of using c as an output parameter?

No. In Ada functions take multiple "in" parameters, and return only
one value via the "return" machanisim. If you have multiple values you
need to return, you should be using a procedure, not a function.

Given that, yes there are some ways to hack it. You can hack it the
same way C coders have hacked it since 1970; by passing in a pointer
to an object instead of the object itself. There is also the Rosen
trick (which is not something we should really get into with a newbie,
it relies on several things you probably don't even know about yet,
and has some weird gotchas). You could also make the character the
"return" value, and use exceptions rather than a boolean.

What method to use really depends a lot on your situation, so it would
be nice to have a little more information on *why* you want to do
this. Any one of the above can be the most appropirate method, or
completely unappropriate, depending on what you are trying to do.


-- 
T.E.D.
Home     -  mailto:dennison@telepath.com (Yahoo: Ted_Dennison)
Homepage -  http://www.telepath.com/dennison/Ted/TED.html



  parent reply	other threads:[~2002-04-15 15:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-14 18:29 Out parameters in a function Nazgul
2002-04-14 19:45 ` David C. Hoos, Sr.
2002-04-15 10:49 ` John McCabe
2002-04-15 11:51   ` John McCabe
2002-04-15 13:43 ` Steve Doiel
2002-04-15 15:09 ` Ted Dennison [this message]
2002-04-16  8:49   ` John McCabe
2002-04-16 10:05     ` Dmitry A. Kazakov
2002-04-16 15:26       ` John McCabe
2002-04-16 19:34         ` Matthew Woodcraft
2002-04-16 20:10           ` Darren New
2002-04-17  1:30             ` Kent Paul Dolan
2002-04-17 16:15               ` Darren New
2002-04-19 17:39               ` Florian Weimer
2002-04-17 13:24             ` Stephen Leake
2002-04-17 16:32               ` Darren New
2002-04-17 21:03               ` Kent Paul Dolan
2002-04-18 12:14             ` Wolfgang Gellerich
2002-04-18 13:52               ` Dmitry A. Kazakov
2002-04-18 16:28                 ` Darren New
2002-04-17 10:17           ` John McCabe
2002-04-16 19:58         ` Kent Paul Dolan
2002-04-16 20:00         ` Kent Paul Dolan
2002-04-17  4:40           ` Jim Rogers
2002-04-17  5:27             ` Kent Paul Dolan
2002-04-17  5:50             ` Eric G. Miller
2002-04-24  2:45               ` David Thompson
2002-04-19 17:40             ` Florian Weimer
2002-04-19 18:26               ` Jim Rogers
2002-04-19 18:53                 ` Florian Weimer
2002-04-17  7:57           ` Dmitry A. Kazakov
2002-04-17 10:21             ` John McCabe
2002-04-24 17:21             ` Warren W. Gay VE3WWG
2002-04-26  7:32               ` Dmitry A. Kazakov
2002-04-15 16:24 ` Stephen Leake
2002-04-16 13:38   ` Ted Dennison
2002-04-17 11:55 ` Ingo Marks
replies disabled

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