comp.lang.ada
 help / color / mirror / Atom feed
* What evil would happen?
@ 2003-07-11 19:51 Wojtek Narczynski
  2003-07-11 20:07 ` Hyman Rosen
                   ` (5 more replies)
  0 siblings, 6 replies; 48+ messages in thread
From: Wojtek Narczynski @ 2003-07-11 19:51 UTC (permalink / raw)


Hello,

What would happen if a procedure could return a value like a function,
or a function could accept an out parameter? Would it make procedures
less procedural? Or impure functions even less impure? Or is there a
reason for this in compiler implementation details?

I feel like with SML like tagged union datatypes I'd be done long
ago... Is there an AI for this maybe?

I am trying to create a parser for CLFF files.

Regards,
Wojtek



^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: What evil would happen?
@ 2003-07-11 23:04 Beard, Frank Randolph CIV
  2003-07-12 12:46 ` Wojtek Narczynski
  0 siblings, 1 reply; 48+ messages in thread
From: Beard, Frank Randolph CIV @ 2003-07-11 23:04 UTC (permalink / raw)
  To: comp.lang.ada

-----Original Message-----
From: Hyman Rosen

>Wojtek Narczynski wrote:
>> What would happen if a procedure could return a value like a function,
>> or a function could accept an out parameter?

> I don't know Ada well enough to answer this myself,
> so I'll ask here - can you make a generic function
> with generic parameters which correspond to the out
> parameters that you would like to pass into the
> function, and have the function write to those? If
> so, is that an acceptable workaround?

Well, if you really wanted the C/C++ function characteristics
for whatever reason, you could use aliased types and pass them
as access parameters to the function.

      type X_Type is ...

      function Do_Something (to_X : access X_Type) return integer;

      function Do_Something (to_X : access X_Type) return integer is
      begin
         ...
         to_X.all := ...;  -- update to_X
         ...
         return 0;
      exception
        when others => return -1;
      end Do_Somthing;

      x           : aliased X_Type;
      return_Code : integer := 0;

   begin

      ...
      return_Code := Do_Something(to_X => x'access);
      ...


Sorry I didn't have time to come up with something more concrete,
but hopefully you get my meaning.

Hope it helps.
Frank



^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2003-07-19  0:55 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-11 19:51 What evil would happen? Wojtek Narczynski
2003-07-11 20:07 ` Hyman Rosen
2003-07-12 12:30   ` Wojtek Narczynski
2003-07-12 17:17     ` Martin Dowie
2003-07-13  1:46     ` Hyman Rosen
2003-07-13 15:29       ` Wojtek Narczynski
2003-07-11 20:08 ` chris.danx
2003-07-12  4:31   ` Nick Roberts
2003-07-12 12:26     ` Wojtek Narczynski
2003-07-12 12:39       ` Preben Randhol
2003-07-12 13:11         ` Larry Kilgallen
2003-07-12 13:22           ` Preben Randhol
2003-07-12 19:04             ` Larry Kilgallen
2003-07-14  8:43               ` Preben Randhol
2003-07-14 10:32                 ` Larry Kilgallen
2003-07-14 11:05                   ` Preben Randhol
2003-07-14 11:31                   ` Larry Kilgallen
     [not found]                   ` <slrnbh53ir.48d.Organization: LJK Software <zSeTW0M3CTPU@eisner.encompasserve.org>
2003-07-14 17:31                     ` Wojtek Narczynski
2003-07-13 15:26             ` Wojtek Narczynski
2003-07-13 17:28               ` Chad R. Meiners
2003-07-13 22:35                 ` Wojtek Narczynski
2003-07-14  0:06                   ` Chad R. Meiners
2003-07-13 22:36                 ` Wojtek Narczynski
2003-07-14  3:01                 ` Hyman Rosen
2003-07-14  4:41                   ` Chad R. Meiners
2003-07-14 23:32                   ` [ot] languages & academia was " chris.danx
2003-07-14  9:09                 ` Dmitry A. Kazakov
2003-07-14 17:44                   ` Chad R. Meiners
2003-07-14 18:15                     ` tmoran
2003-07-15  8:06                     ` Dmitry A. Kazakov
2003-07-11 21:26 ` Robert I. Eachus
2003-07-12 12:38   ` Wojtek Narczynski
2003-07-16  0:07     ` Robert I. Eachus
2003-07-16  8:11       ` Preben Randhol
2003-07-14 18:52 ` Randy Brukardt
2003-07-14 20:12   ` Hyman Rosen
2003-07-15  2:32   ` Alexander Kopilovitch
2003-07-15  8:19   ` Wojtek Narczynski
2003-07-15 17:33     ` Randy Brukardt
2003-07-16  0:22       ` Robert I. Eachus
2003-07-16  8:36       ` Dmitry A. Kazakov
2003-07-15  5:16 ` Kenneth Almquist
2003-07-15 11:31   ` Wojtek Narczynski
2003-07-18  8:23 ` Wojtek Narczynski
2003-07-18 14:45   ` Hyman Rosen
2003-07-19  0:55   ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
2003-07-11 23:04 Beard, Frank Randolph CIV
2003-07-12 12:46 ` Wojtek Narczynski

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