Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #42569

Re: CATCH and THROW

From rickman <gnuarm@gmail.com>
Newsgroups comp.lang.forth
Subject Re: CATCH and THROW
Date 2015-10-11 04:16 -0400
Organization A noiseless patient Spider
Message-ID <mvd5pc$601$1@dont-email.me> (permalink)
References (1 earlier) <op.x59sxir7yfako5@localhost> <mvcde8$7la$1@speranza.aioe.org> <3af8e118-f284-449f-8da0-883fc125790c@googlegroups.com> <mvcvm1$jh9$1@dont-email.me> <87twpx3nkg.fsf@jester.gateway.sonic.net>

Show all headers | View raw


On 10/11/2015 2:51 AM, Paul Rubin wrote:
> rickman <gnuarm@gmail.com> writes:
>> If a response timed out or was received invalid, the CATCH/THROW
>> mechanism allowed the code to more easily find its way back to either
>> retrying the operation or exitingn....  Trying to code this in more
>> conventional flow control resulted in a mess of flag checking
>
> You could also do this with a multitasker.  In the error case, the
> serial port task would send a message to the control task, then jump
> back to the top of its own event loop.  This is usually cleaner when
> there are asynchronous events and timeouts in a system.

Multitaskers may not be overly hard, but they are not trivial to design. 
  The serial data protocol is not async, it is command/response.  The 
timeout is waiting for a "valid" reply.  The incoming message is parsed 
and if it is not correctly formatted, especially if it is not terminated 
by the newline, it is not treated as received.

Even if a multitasker is used, this doesn't really help to cut through 
the messy error handling in the many words involved.  You still need to 
code handling the error condition in the many words of serial protocol 
task as well as handling it in every word called in the control task.

The position in the higher level code (control "task") gives insight to 
the nature of the problem and how to handle the failure, but lower level 
words detect the error while handling the protocol.  So the CATCH/THROW 
connection is the most expedient way to get from low level error to high 
level handler.

I wish I had considered error detection and handling when the code was 
first written, but I didn't know about CATCH/THROW then.  I only learned 
about it after I had the explicit need.  The kind folks here gave me a 
few pointers and much advice.

-- 

Rick

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

CATCH and THROW Mark Wills <markwills1970@gmail.com> - 2015-10-09 05:46 -0700
  Re: CATCH and THROW anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-09 16:05 +0000
    Re: CATCH and THROW "Elizabeth D. Rather" <erather@forth.com> - 2015-10-09 08:30 -1000
      Re: CATCH and THROW JennyB <jennybrien@googlemail.com> - 2015-10-09 12:19 -0700
        Re: CATCH and THROW Mark Wills <markwills1970@gmail.com> - 2015-10-09 12:30 -0700
  Re: CATCH and THROW "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-10-09 23:21 -0400
    Re: CATCH and THROW Paul Rubin <no.email@nospam.invalid> - 2015-10-09 20:37 -0700
    Re: CATCH and THROW Mark Wills <markwills1970@gmail.com> - 2015-10-10 01:16 -0700
      Re: CATCH and THROW Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-10-10 19:18 +0100
    Re: CATCH and THROW "HAA" <someone@microsoft.com> - 2015-10-11 12:18 +1000
      Re: CATCH and THROW hughaguilar96@gmail.com - 2015-10-10 23:21 -0700
        Re: CATCH and THROW rickman <gnuarm@gmail.com> - 2015-10-11 02:32 -0400
          Re: CATCH and THROW Paul Rubin <no.email@nospam.invalid> - 2015-10-10 23:51 -0700
            Re: CATCH and THROW rickman <gnuarm@gmail.com> - 2015-10-11 04:16 -0400
              Re: CATCH and THROW Paul Rubin <no.email@nospam.invalid> - 2015-10-11 23:27 -0700
                Re: CATCH and THROW rickman <gnuarm@gmail.com> - 2015-10-12 02:39 -0400
                Re: CATCH and THROW "Elizabeth D. Rather" <erather@forth.com> - 2015-10-11 21:26 -1000
              Re: CATCH and THROW "Elizabeth D. Rather" <erather@forth.com> - 2015-10-11 21:22 -1000
        Re: CATCH and THROW "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-10-12 01:29 -0400
          Re: CATCH and THROW rickman <gnuarm@gmail.com> - 2015-10-12 02:23 -0400
            Re: CATCH and THROW "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-10-12 19:52 -0400
              Re: CATCH and THROW rickman <gnuarm@gmail.com> - 2015-10-12 21:14 -0400
      Re: CATCH and THROW "Elizabeth D. Rather" <erather@forth.com> - 2015-10-10 21:19 -1000

csiph-web