News for hackers. Stuff that matters.
Re:Algebraic Data Types for C99 by linkdd on Thursday May 09, 2024 @08:58AM (#40307747)
This is the work of a wizard.

I've known C for almost 20 years, and never would I have thought the macro system was powerful enough to allow such black magic.

This is awesome!

Re:Algebraic Data Types for C99 by cl91 on Thursday May 09, 2024 @11:16AM (#40309097)
> I've known C for almost 20 years

The author is only 19 years old. I feel really dumb now.

Re:Algebraic Data Types for C99 by clnhlzmn on Thursday May 09, 2024 @09:33AM (#40308068)
You might also be interested in metalang99 by the same author.
Re:Algebraic Data Types for C99 by jacoblambda on Thursday May 09, 2024 @09:49AM (#40308231)
Yeah xmacros (the style of macro use) are pretty fancy. "Classically" they are used for creating and accessing type safe generics or for reducing boilerplate for hardware register and interrupt definitions.

They are kind of cursed but at their core they are actually incredibly simple and a reliable tool for reducing cognitive complexity and boilerplate in C based projects.

Re:Algebraic Data Types for C99 by lupire on Thursday May 09, 2024 @09:29AM (#40308016)
ADTs are mostly string replacement on generic structs and unions, plus tagging on the union. It's not a complicated use of macros.