Remix.run Logo
▲ rramadass a day ago

Also see Templates in C by David Priver - https://www.davidpriver.com/ctemplates.html

He also has other interesting C techniques, namely;

Adding reflection to C - https://news.ycombinator.com/item?id=49964525

_Generic for Type Reification in C - https://www.davidpriver.com/creification.html

See also his C2y interpreter with REPL named "DrC" for the upcoming C29 standard (https://en.wikipedia.org/wiki/C29_(C_standard_revision)) - https://github.com/drpriver/drc

PS: I really like his style of writing and presentation; concise and precise without unnecessary fluff and page beautifying.

▲david2ndaccount a day ago | parent | next [-]

Hey that’s me! Cool to see people like my stuff.

▲rramadass a day ago | parent | next [-]

You should write more ;-)

I also posted your "Adding Reflection to C" at https://news.ycombinator.com/item?id=49964525 and hope HN picks up on it and has a decent discussion.

You definitely should add a detailed post on your "DrC" compiler/interpreter; usecase, scope, techniques used etc. Since this is looking forward to C2y/C29 with some more extensions, i think people will enjoy playing with it in the REPL format.

▲david2ndaccount a day ago | parent [-]

I agree. Alas I have a day job and my other hobby is going for long hikes. But when the days get shorter and the weather is worse I’ll write some more!

▲warmwaffles a day ago | parent | prev [-]

I do wish to see comptime stuff in C some day. Or at a minimum your `defblock` implemented. I am so tired of having to escape new lines.

▲uecker a day ago | parent [-]

There is a proposal for #def / #enddef:

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3531.txt

▲MFHava 20 hours ago | parent [-]

Oh great, the next C-hack C++ will have to adopt for compatibility...

▲uecker 15 hours ago | parent [-]

Why do you think this is a hack? Also C++ does not have to adopt it. (but it probably would)

▲podocarp a day ago | parent | prev [-]

Lol at some point just implement a small compiler in C… reflection is kinda a hilarious thing to have like I understand the use case for generics, since it's not that that that hard to do with macros and quite commonly wished for