That's quite an interesting question. Is it better to have multiple
exits or to have GOTOs that branch to a common exit point? It seems
rather arcane, but two questions come to mind:

1. Is the single exit point used to ensure that all "cleanup" code is
in the same place?

2. Do you have multiple "normal" exits, or do the others correspond to
exceptional conditions?


--- Kevin Toppenberg <[EMAIL PROTECTED]> wrote:

> Greg,
>  I use the GOTO because I always set things up such that every
> function has 
> only ONE exit point. That way if I come back later, and I want to do 
> something in the function before it exits, I can put the code at the
> end. 
> But if I have QUITS scattered about, then its more messy.
>  And no I haven't started abreviating code. I was just picking
> through 
> existing code and trying to make it as easy for others when I posted
> here.
>  Thanks!
>  Kevin
> 
>  On 9/13/05, Greg Kreis <[EMAIL PROTECTED]> wrote: 
> > 
> > It quits the FOR loop. I believe the code is better written with
> the
> > QUIT instead of the GOTO.
> > 
> > S EX=0
> > F D0=0:0 DO Q:EX
> > . S D0=$O(^UTILITY(U,$J,DDF(1),D0))
> > . S:D0="" D0=-1
> > . I '$D(^UTILITY(U,$J,DDF(1),D0,0)) S EX=1 Q
> > . S Z=^UTILITY(U,$J,DDF(1),D0,0)
> > . D I^DITR
> > 
> > BUT, BUT, BUT.... did you notice all the code that had to be
> converted
> > to full global references to be compliant with VA programming
> standards
> > on the use of naked references? (The rule in the SACC about no line
> > starting with a naked reference is a sound one, BTW, born of
> > experience.) Also, you have to add a semaphore (EX in this case) if
> you
> > want to avoid checking the global existence repeatedly. You can see
> > that by stretching the code out over several lines (what I
> generally
> > recommend) in this case made the code more verbose because we now
> have
> > to manage what the context was handling when all on one line in the
> loop.
> > 
> > Isn't it eye opening to see how many subtleties are in M code? (I
> am
> > not sure why they wanted to set D0=-1 unless they were going to
> > encounter problems with it being null beyond just the null
> subscript
> > error in the global reference that follows the check and set of
> D0.)
> > 
> > P.S.
> > I notice you have taken to abbreviating commands... ;-) or are you
> just
> > tearing apart something already written?
> > 
> > 
> > Kevin Toppenberg wrote:
> > 
> > >Hey all,
> > >
> > >I am working with this line of code:
> > >
> > >F D0=0:0 S D0=$O(^UTILITY(U,$J,DDF(1),D0)) S:D0=""
> > >D0=-1 Q:'$D(^(D0,0)) S Z=^(0) D I^DITR
> > >
> > >
> > >My question, does the QUIT in this line quit the For
> > >loop, or quit the function?
> > >
> > >Would this be equivalent code:
> > >
> > >F D0=0:0 DO GOTO:'$D(^(D0,0)) LABEL1
> > >. S D0=$O(^UTILITY(U,$J,DDF(1),D0))
> > >. S:D0="" D0=-1
> > >. Q:'$D(^(D0,0))
> > >. S Z=^(0)
> > >. D I^DITR
> > >
> > >LABEL1
> > > QUIT
> > >
> > >
> > >Thanks
> > >Kevin
> > >
> > >
> > >
> > >__________________________________
> > >Do you Yahoo!?
> > >Check out the new Yahoo! Front Page.
> > >www.yahoo.com <http://www.yahoo.com>
> > >
> > >
> > >
> > >
> > >-------------------------------------------------------
> > >This SF.Net email is sponsored by:
> > >Sybase ASE Linux Express Edition - download now for FREE
> > >LinuxWorld Reader's Choice Award Winner for best database on
> Linux.
> > >http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
> > >_______________________________________________
> > >Hardhats-members mailing list
> > >[email protected]
> > >https://lists.sourceforge.net/lists/listinfo/hardhats-members
> > >
> > >
> > >
> > 
> > --
> > Greg Kreis http://www.PioneerDataSys.com
> > 
> > "You are today where your thoughts have brought you, you will
> > be tomorrow where your thoughts take you." (James Lane Allen)
> > 
> > 
> > 
> > -------------------------------------------------------
> > SF.Net email is sponsored by:
> > Tame your development challenges with Apache's Geronimo App Server.
> 
> > Download
> > it for free - -and be entered to win a 42" plasma tv or your very
> own
> > Sony(tm)PSP. Click here to play:
> http://sourceforge.net/geronimo.php
> > _______________________________________________
> > Hardhats-members mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/hardhats-members
> >
> 



===
Gregory Woodhouse  <[EMAIL PROTECTED]>



"Without the requirement of mathematical aesthetics a great many discoveries 
would not have been made."

-- Albert Einstein











-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Hardhats-members mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to