Because of popular request, here is the pastebin (as I do not want this anywhere near my github).
Added comments as well to save some headaches
edit: idk how it happened, but a logic bug slipped in. In dynamic_cast, offsetof(To, From) should be changed to offsetof(From, To). Additionally, I forgot to make it type-safe, which can easily be done by changing (char *)(DYNAMIC_CAST_ to (char *)(0 ? (From *) : DYNAMIC_CAST_
edit: I’ve decided to extend it a bit and put it on GitHub as well
After looking at the macro code, I believe they just become struct fields. So instance variables.
I don't know what you are even saying. I thought properties were like instance variables except access automatically goes through getter and setter methods.
Yeah, of course you can have whatever get and set logic you want. Or not even provide a setter and make the property read-only. I was thinking it would also create a private field with the same name of the property for you, but now I'm not sure.
But I have done so in the past; this method can be extended to include them, if somebody would even desire to do that. Just requires the necessary outer and inner generations in a different selector
All to make it cleaner to appear even more magical haha. One of my previous posts actually implements actual vtables with similar wrappers (kind of hidden, but it’s why things are passed by address to print for example), but it becomes quite a bit messier quite fast
Have this rattling around my head and it I can’t shake how amazing it is. It’s like the code you posted at first is the setup and the macros are the punchline.
Well yeah mostly. The only complicated part was the selector mechanism and being able to pass the class name to them because it’s not part of the parameter pack
Back in the 90s, I remember a guy invented a C-like language, and called it C--. I downloaded his compiler from a local BBS, using my 14.4kbps dialup modem.
C— is actually a stripped down version of C used in code generation by compilers of some functional programming languages. With the title I hoped someone would mention it already being a thing
I don’t know which brackets you’re referring to in particular, but there are a lot of parentheses because it’s all C preprocessor macro expansions and token grouping for within macro expansion
I love it, but I don't necessarily see why one would use it. Serious question: is there a way to get the compiler to display the final result of macro expansion? (If not, then how long did it take to come up with and debug this black magic?)
72
u/TheChief275 Nov 27 '25 edited Dec 01 '25 •
Because of popular request, here is the pastebin (as I do not want this anywhere near my github).
Added comments as well to save some headaches
edit: idk how it happened, but a logic bug slipped in. In dynamic_cast, offsetof(To, From) should be changed to offsetof(From, To). Additionally, I forgot to make it type-safe, which can easily be done by changing (char *)(DYNAMIC_CAST_ to (char *)(0 ? (From *) : DYNAMIC_CAST_
edit: I’ve decided to extend it a bit and put it on GitHub as well
207
u/Haringat Nov 27 '25
Is that c with the weirdest preprocessor macros ever?
40
u/val_tuesday Nov 27 '25
How did you manage “as”!? Also vtables with just macros!?
You have to share, this looks like wizardry.
16
u/LeeHide Nov 27 '25
Finally, a shitty lisp in my C
14
u/elkvis Nov 27 '25
Back in the 90s, I remember a guy invented a C-like language, and called it C--. I downloaded his compiler from a local BBS, using my 14.4kbps dialup modem.
9
u/[deleted] Nov 27 '25
share the macro lord
2
u/lbfalvy Dec 02 '25
Libcello but worse
105
u/creativityNAME Nov 27 '25
C please please 🙏
24
u/Rolling-Thunderbird Nov 27 '25
at this point just switch to asm twin
16
u/dydhaw Nov 27 '25
Abjective C
6
u/Dddfuzz Nov 27 '25
I love it, no notes. Easiest way to spot a dev who actually likes programming
4
u/R0NIN49 Nov 27 '25
This is diabolical work.
1
u/SpecialMechanic1715 Nov 27 '25
why brackets?
1
u/Jonathan_the_Nerd Nov 28 '25
Why do you have a Unicode rightward arrow in your C code? Did I miss that update to the C spec?
1
u/Amazing-Stuff-5045 Dec 03 '25
I love it, but I don't necessarily see why one would use it. Serious question: is there a way to get the compiler to display the final result of macro expansion? (If not, then how long did it take to come up with and debug this black magic?)
3
u/xcski_paul Nov 27 '25
I thought BourneGol was a crime against nature. This is worse.
2
u/[deleted] Nov 28 '25
This is what professionals refer to as a "LISPlike"
1
u/uvero Nov 27 '25
I like it, it's fun.
1
u/SingleProtection2501 Nov 28 '25
What the fuck is that 💔
1
u/Mithrandir2k16 Nov 28 '25
Nice, add smart pointers and it'll be all I want from c++ lol
1
u/Thenderick Nov 28 '25
"Fuck you!"
lisps your C
1
u/BatticusRhoe Nov 28 '25
C♭
Am I right!? ✋😃
1
u/Mission-Wasabi-7682 Nov 28 '25
Why? 😭
1
u/Dismal_Dimension_274 Nov 30 '25
Foo bar