/plushcap/analysis/redis/redis-if-you-think-goto-is-a-bad-idea

If You Think Goto Is a Bad Idea, What Would You Say About Longjmp?

What's this blog post about?

The text discusses the use of goto statements in programming and their potential benefits in certain situations. It provides an example where using goto can simplify code by allowing for a cleaner and less error-prone design when managing resources like memory allocation. Additionally, it explores the concept of exception handling in C, which lacks built-in support for this feature found in other high-level languages. The author presents various approaches to implement try-catch logic in C, ultimately settling on using longjmp as a solution that allows jumping from anywhere within the call stack and restoring the stack automatically. This approach is demonstrated through an example of error reporting in a RedisGraph query execution context.

Company
Redis

Date published
Sept. 16, 2019

Author(s)
Roi Lipman

Word count
949

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.