[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC][PATCH] pkl: make PK_UNREACHABLE more verbose

From: Bruno Haible
Subject: Re: [RFC][PATCH] pkl: make PK_UNREACHABLE more verbose
Date: Tue, 14 Feb 2023 00:38:35 +0100

Mohammad-Reza Nabipoor wrote:
> In this patch I improved the `PK_UNREACHABLE' a little bit, but ...
> Do you think it's a good idea to use `setjmp'/`longjmp' to handle
> these kind of internal errors?
> Because libpoke is a library, and it's better for libraries to not
> abort.

One hears that frequently: "libraries should not abort".

I think, libraries should not abort when
  - the input is unexpected, or
  - memory is exhausted. (*)

But for internal errors, that is, situations where developer attention is
needed, it's best to call abort(). So that the user has an incentive to
report the problem.

In projects which don't have a feedback loop with users (via a bug tracker)
and additionally have a suboptimal test coverage, it can be tempting to paper
over bugs and just continue instead of abort()ing. But this (IMHO) bad coding
practice is just a symptom of the previously bad situation (missing feedback
loop and lack of test coverage).


(*) Well done, poke hackers: An input file with a couple of thousand
opening braces or opening parentheses does not abort poke, but gets to the
input prompt:

(poke) .load /home/bruno/foo.pk
/home/bruno/foo.pk:63:39: error: memory exhausted

reply via email to

[Prev in Thread] Current Thread [Next in Thread]