That's rather like the use of "magic" return values in C, as in

while ((c = getchar()) != EOF)
  putchar(c);

It's a handy shorthand, but it has the disadvantage of mixing result
types. Normally, c is a character, and sometimes it's a sentinel value
like EOF. To me, this is reasonably tolerable (though not ideal)
because EOF can be thought of a kind of pseudocharacter). Much worse,
though is

result = do_something_dangerous();

switch(result) {

case 0:
 value = result;
break;

...

case 10:
  fprintf(stderr, "Error number 10 occured!\n");
value = -1;
}

--- Aylesworth Marc A Ctr AFRL/IFSE <[EMAIL PROTECTED]> wrote:

> Could you also do this:
> 
> 
> 
> 
> 
> MyFunct(a,b)
>   new result 
>   if $get(a)="" set result=-1
>   if $get(b)="" set result=-1
> 
>   set result=a*b
>   ;//more code here.
> 
>   quit result
> 
> one exit and result is always set.
> 
> 
> Thanks
> 
> Marc Aylesworth
> 
> C3I Associates 
> 
> AFRL/IFSE
> 
> Joint Battlespace Infosphere Team
> 
> 525 Brooks Rd
> 
> Rome, NY 13441-4505
> 
> Tel:315.330.2422
> 
> Fax:315.330.7009
> 
> Email: [EMAIL PROTECTED]
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Chris
> Richardson
> Sent: Wednesday, September 14, 2005 9:42 PM
> To: hardhats-members@lists.sourceforge.net
> Subject: Re: [Hardhats-members] Re: More easy M syntax questions
> 
> Kevin;
> 
>    I feel the same way about curley braces (in C and other legitimate
> languages).  I find it so strange to see which closing brace goes
> with which
> opening brace.
> 
>   I have programmed in FORTRAN and APL before MUMPS and was very
> happy to
> NOT use the GOTO in MUMPS.  Now the exit on condition can be
> abbomplished
> with a consistant set of exit actions by installing a dot block which
> allows
> for the negative/positive actions to decide an action and then to
> exit.  It
> is what I call a herring bone filter.  Here is a simplified form;
> 
> EVALU8(A,B) ; Evaluate the string passed as A, contition returned in
> B
>  N E,X
>  S B=$G(B)
>  S E=$G(A)
>  S X="999;Unidentified Error: "_E
>  D
>  .  I A?1.N      S X="0;Numeric: "_E            Q
>  .  I A?1.AN   S X="0;AlphaNumeric: "_E   Q
>  .  ;  As many conditions as needed go here, but when the situation
> is
> found, exit the block.
>  .  ;  Else was a precondition
>  .QUIT
>  S:'X B="Success"
>  QUIT X
>   ;  ==============
> 
> 
> 
> 
> 
> ----- Original Message -----
> From: "Kevin Toppenberg" <[EMAIL PROTECTED]>
> To: <hardhats-members@lists.sourceforge.net>
> Sent: Wednesday, September 14, 2005 5:17 PM
> Subject: [Hardhats-members] Re: More easy M syntax questions
> 
> 
> I have always been taught that goto's should be avoided like the
> plague.  And that is the general rule I have always followed before
> working with M.
> 
> One issue is that having to nest block of code with leader dots (e.g.
> . . . S I=1), makes it more awkard in my opion.  So it becomes easier
> to have this:
> 
> MyFunct(a,b)
>   new result set result=-1
>   if $get(a)="" goto FuncDone
>   if $get(b)="" goto FuncDone
> 
>   set result=a*b
>   ;//more code here.
> 
> FuncDone
>   quit result
> 
> 
> as compared to
> 
> MyFunct(a,b)
>   new result set result=-1
>   if ($get(a)'="")&($get(b)="") do
>   . set result=a*b
>   . ;//more code here
> 
> FuncDone
>   quit result
> 
> 
> Another issue is that the for loops in M don't have a "break" or
> "continue" command, which makes the syntax a bit more awkward.
> 
> Kevin
> 
> 
> On 9/14/05, Greg Woodhouse <[EMAIL PROTECTED]> wrote:
> > The reason I care is that I've been thinking about code analysis
> and
> > code generation lately. One topic of special inteest to me is
> > concurrent and distributed processing, and I've been thinking about
> > ways of effectively using multiprocessors to run sequential
> programs.
> >
> > --- Greg Woodhouse <[EMAIL PROTECTED]> wrote:
> >
> > > I was referring to the GOTOs as the "exits", not the QUIT.
> > >
> > > In another language, would your code have been something like
> this
> > >
> > > try
> > >  Your code here
> > >
> > > except e1
> > >  Handle exceptional condition 1
> > >
> > > ...
> > >
> > > except en
> > >   Handle exceptional condition n
> > >
> > > finally
> > >   "Cleanup" code goes here
> > >
> > > Normal exit here
> > >
> > >
> > > --- Kevin Toppenberg <[EMAIL PROTECTED]> wrote:
> > >
> > > > See below
> > > >
> > > > On 9/14/05, Greg Woodhouse <[EMAIL PROTECTED]>
> wrote:
> > >
> > > > >
> > > > > 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?
> > > >
> > > >   Yes. Also to make sure that my return values for the function
> are
> > > > properly
> > > > set etc.
> > > >
> > > > 2. Do you have multiple "normal" exits, or do the others
> correspond
> > > > to
> > > > > exceptional conditions?
> > > >
> > > >  No, I only have one exit.
> > > >  Thanks
> > > > Kevin
> > > >
> > > > --- 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>
> <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
> > > > > > > >Hardhats-members@lists.sourceforge.net
> > > > > > >
> > > >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
> > > > > > > Hardhats-members@lists.sourceforge.net
> > > > > > >
> 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
> > > > > Hardhats-members@lists.sourceforge.net
> > > > > 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
> > > Hardhats-members@lists.sourceforge.net
> > > 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
> > Hardhats-members@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/hardhats-members
> >
> 
> 
> -------------------------------------------------------
> 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
> Hardhats-members@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hardhats-members
> 
> 
> 
> 
> 
> 
> -------------------------------------------------------
> 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
> Hardhats-members@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hardhats-members
> 
> 
> -------------------------------------------------------
> 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
> Hardhats-members@lists.sourceforge.net
> 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
Hardhats-members@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to