High-level constructs for low-level C: exception handling, RAII, sum types and pattern matching

You guys might get a kick out the recent macro abuse I've been playing around with. The sum types/pattern matching are straightforward, but perhaps of more interest here, the exception handling form is that first suggested by Andrew Kennedy and Nick Benton in Exceptional Syntax, and later generalized in Handlers of Algebraic Effects.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Neat. Check out:

Neat.

Check out:

SGLIB - A Simple Generic Library for C, which was published about in A Simple Generic Library for C
and
c-generic-library: A generic data structure library modeled after C++ STL. by Micah Villmow
and
Walter Bright passes along The X Macro
and... I know from a recent previous thread on LtU that you are already familiar with:
Protothreads

Thanks, I'm familiar with

Thanks, I'm familiar with most of those, though c-generic-library is new. It seems to use the same strategies as sglib of lifting many functions into macros, which I really don't like for readability and debugging reasons.

I've previously hinted at overloading and parametric polymorphism in C, which I'm doing with a simple X-macro scheme. Parametric types and functions are defined like ordinary C types and functions on variables of type T, ie. struct list(T) { T value; struct list(T)* next; }.

I'm not totally happy with it yet, but I can provide more details privately if anyone is interested.