comp.lang.ada
 help / color / mirror / Atom feed
From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject: Re: Local vs global variables in ADA
Date: Wed, 06 Nov 2002 16:25:03 -0800
Date: 2002-11-07T02:44:30+00:00	[thread overview]
Message-ID: <0tbcqa.nk3.ln@beastie.ix.netcom.com> (raw)
In-Reply-To: 27331d9e.0211060640.6cb14b24@posting.google.com

john mann fed this fish to the penguins on Wednesday 06 November 2002 
06:40 am:

> Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote in message
> news:<p0u9qa.4p3.ln@beastie.ix.netcom.com>... <snip>
>>         And /neither/ structure really handles the form where you
>>         need a bit
>> of processing before you can do the test...
>> 
>> 
>>         loop
>>                 preprocessing which sets flag
>>             exit when <cond>
>>                 other processing
>>         end loop.
>> 
> 
> 
> Well, you could use a function to get the while test value.
> Couldn't you?

        Most of my experience is in FORTRAN, avoiding vendor specific 
extensions, but still... writing whole function WITH SIDE-EFFECTS and 
calling overhead to change

        read(unit,format, iostat=ios) v1, v2, v3
  10    if (ios .ne. EOF_VALUE) then
                other processing
                read(unit,format, iostat=ios) v1, v2, v3
        goto 10
        endif

into
        integer function funcwithsideeffects(a1,a2,a3)
        read(unit,format, iostat=is) a1, a2, a3
        funcwithsideeffects = is
        return

        ...

  10    if (funcwithsideeffects(v1,v2,v3) .ne. EOF_VALUE) then
                other processing
        goto 10
        endif

        
        Would have gotten jeers from code inspections at my former employer. 
Especially as I'd have to document/justify the creation of those 
snippet functions.

        As it is, I only used "goto" in constructs where the destination was 
before the goto (as anyone reading the code should have seen the target 
already, and not have to search). This is why I did not fake the Ada 
loop/exit when/end loop in FORTRAN... If I had, the result would have 
looked like:

   10   continue
                read(unit,format, iostat=ios) v1, v2, v3
                if (ios .eq. EOF_VALUE) goto 20
                other processing
        goto 10
   20   continue


        Granted, Ada's I/O system is such that creating a procedure to 
consolidate the three variable reads into one is feasible -- but again, 
to put the status return into it still requires a function with 
side-effects if one wants to use while ... loop/end loop




--  
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



  reply	other threads:[~2002-11-07  0:25 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-03 18:17 Local vs global variables in ADA Roger
2002-11-03 19:03 ` Per Sandbergs
2002-11-03 19:31 ` Eric Jacoboni
2002-11-04  1:47 ` Jeffrey Carter
2002-11-04 13:27   ` Wes Groleau
2002-11-04 20:48     ` Jeffrey Carter
2002-11-05  8:43       ` Fraser Wilson
2002-11-05 13:53         ` Charles H. Sampson
2002-11-06  4:59           ` R. Tim Coslet
2002-11-05 17:28         ` Stephen Leake
2002-11-05 17:38           ` Jean-Pierre Rosen
2002-11-05 19:57             ` Jeffrey Carter
2002-11-06  9:11               ` Jean-Pierre Rosen
2002-11-05 20:26             ` Vinzent Hoefler
2002-11-05 23:14             ` Wes Groleau
2002-11-06  9:16               ` Jean-Pierre Rosen
2002-11-06 13:49                 ` Wes Groleau
2002-11-05 22:37           ` Robert A Duff
2002-11-05 23:46             ` Larry Hazel
2002-11-06  2:19               ` Dennis Lee Bieber
2002-11-06 13:45                 ` Dan Nagle
2002-11-07  0:30                   ` Dennis Lee Bieber
2002-11-06  2:15             ` Dennis Lee Bieber
2002-11-06  7:04               ` Martin Dowie
2002-11-06 14:40               ` john mann
2002-11-07  0:25                 ` Dennis Lee Bieber [this message]
2002-11-07 14:58                   ` Robert A Duff
2002-11-07 15:38                     ` Jean-Pierre Rosen
2002-11-08  1:43                   ` Jeffrey Carter
2002-11-06  7:18             ` Dale Stanbrough
2002-11-06 15:40             ` Rod Chapman
2002-11-06 17:34             ` Stephen Leake
2002-11-10  1:36               ` loop statements, was " David Thompson
2002-11-05 19:54         ` Jeffrey Carter
2002-11-04 13:47 ` Martin Dowie
  -- strict thread matches above, loose matches on Subject: below --
2002-11-05  6:42 Grein, Christoph
2002-11-05 15:59 ` Martin Dowie
replies disabled

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