4 ms·
Show HN: Poica – Algebraic data types and type introspection for pure C
- keeganpoppen 6y agowow that actually looks pretty clean
- deleted 6y ago[deleted]
- Kednicma 6y agoI wonder whether this interacts cleanly with Cello, GTK+, or other "object-oriented" C libraries. It certainly is a nice presentation, if a little baroque.
- dleslie 6y agoThis is ... wild. Usually these things explode in size when compiled, require an external preprocessor, and/or heavily lean on system calls. This does none of those things.
- Riverheart 6y agoDoesn't this require an external preprocessor? The Boost Preprocessor
- rjeli 6y agoNo, boost/preprocessor is a library that offers metaprogramming primitives for the standard C/C++ preprocessor
- syockit 6y agoUnfortunately none of the examples contain malloc, whilst I'm curious as to whether the pattern matching works with heap allocated object. The binary tree example only has statically defined tree, which blows up into lots of code in assembly.
- naasking 6y agoNeat. I wrote a similar header only library a long time ago just for sum types, so it's a little more limited but works for C89 or later IIRC: https://github.com/naasking/libsum https://github.com/naasking/libsum
- igravious 6y agoSo in this case the connection to algebraic data types is that they provide static type checking for unions as well as structs in C along with type introspection which is novel. The linked article explaining the whys and wherefores of ADTs (https://codewords.recurse.com/issues/three/algebra-and-calculus-of-algebraic-data-types https://codewords.recurse.com/issues/three/algebra-and-calcu...) has hit the front page of HN twice now!
- deleted 6y ago[deleted]