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


Groups > comp.lang.c > #72753

Re: Error handling in a parser (return value or setjmp)

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: Error handling in a parser (return value or setjmp)
Date 2015-10-14 11:06 +1300
Message-ID <d85djuFlf7cU5@mid.individual.net> (permalink)
References (3 earlier) <mvjake$fm3$1@speranza.aioe.org> <d851roFlf7cU2@mid.individual.net> <mvjo7n$hac$1@speranza.aioe.org> <slrnn1qufm.5q5.grahn+nntp@frailea.sa.invalid> <mvju7n$uu9$2@speranza.aioe.org>

Show all headers | View raw


Morten W. Petersen wrote:
> On 13.10.2015 23:39, Jorgen Grahn wrote:
>> On Tue, 2015-10-13, Morten W. Petersen wrote:
>>> On 13.10.2015 20:46, Ian Collins wrote:
>>>> Morten W. Petersen wrote:
>>>>> On 13.10.2015 17:26, supercat@casperkitty.com wrote:
>>> [...]
>>>>>
>>>>> Is it possible to look back up in the call stack, to search for a given
>>>>> point and restore to that?
>>>>
>>>> If you want C++ like exception handling, you know whee to look!
>>>
>>> Hmm, no, I don't want to rely on C++. :)
>>>
>>> I found this thing though:
>>>
>>>      http://www.nicemice.net/cexcept/
>>>
>>> Which is a exception system for C.  So there are alternatives, I
>>> just have to find the best one.
>>
>> If you don't want the mechanisms in C++, you probably shouldn't bolt
>> on emulations on top of C either -- /particularly/ not if you're
>> writing a library!
>
> Heh.  Well emulations are on thing, different implementations are
> another..
>
> What kind of overhead does the C++ try/catch thing have?

With current compilers little if any as long as you don't throw.  You 
should be able to get slightly better performance with

try { doSomething(); } catch(..) { handleError(); }

style code than with

if ( !doSomething(); ) handleError();

>> I recommend doing error handling like everyone else does it.
>
> Yes, that is an option that I might use.

s/might/should/

Everyone else does it the way they do for good reasons!

-- 
Ian Collins

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


Thread

Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-13 04:33 +0200
  Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-13 15:54 +1300
    Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-13 05:07 +0200
  Re: Error handling in a parser (return value or setjmp) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-13 14:07 +0100
    Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-13 16:17 +0200
    Re: Error handling in a parser (return value or setjmp) supercat@casperkitty.com - 2015-10-13 08:26 -0700
      Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-13 18:14 +0200
        Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-14 07:46 +1300
          Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-13 22:06 +0200
            Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-14 10:32 +1300
              Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-13 23:47 +0200
                Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-14 11:02 +1300
                Re: Error handling in a parser (return value or setjmp) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-10-14 18:32 +0000
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-15 12:28 +0200
                Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-16 07:47 +1300
            Re: Error handling in a parser (return value or setjmp) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-10-13 21:39 +0000
              Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-13 23:49 +0200
                Re: Error handling in a parser (return value or setjmp) supercat@casperkitty.com - 2015-10-13 15:03 -0700
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-14 01:16 +0200
                Re: Error handling in a parser (return value or setjmp) Geoff <geoff@invalid.invalid> - 2015-10-13 16:46 -0700
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-14 02:13 +0200
                Re: Error handling in a parser (return value or setjmp) Geoff <geoff@invalid.invalid> - 2015-10-13 19:10 -0700
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-14 04:27 +0200
                Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-14 16:05 +1300
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-14 05:18 +0200
                Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-14 16:31 +1300
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-14 05:44 +0200
                Re: Error handling in a parser (return value or setjmp) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-10-15 12:06 +0000
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-15 16:08 +0200
                Re: Error handling in a parser (return value or setjmp) supercat@casperkitty.com - 2015-10-14 00:36 -0700
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-15 12:32 +0200
                Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-14 11:06 +1300
                Re: Error handling in a parser (return value or setjmp) David Brown <david.brown@hesbynett.no> - 2015-10-14 00:10 +0200
                Re: Error handling in a parser (return value or setjmp) James Kuyper <jameskuyper@verizon.net> - 2015-10-13 19:08 -0400
              Re: Error handling in a parser (return value or setjmp) raltbos@xs4all.nl (Richard Bos) - 2015-10-14 11:37 +0000
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-15 12:34 +0200
                Re: Error handling in a parser (return value or setjmp) Ian Collins <ian-news@hotmail.com> - 2015-10-16 07:56 +1300
                Re: Error handling in a parser (return value or setjmp) "Morten W. Petersen" <morphex@gmail.com> - 2015-10-16 05:45 +0200
            Re: Error handling in a parser (return value or setjmp) James Kuyper <jameskuyper@verizon.net> - 2015-10-13 18:53 -0400

csiph-web