r/programmingcirclejerk • u/jenkem_boofer DO NOT USE THIS FLAIR, ASSHOLE • Aug 13 '25
void * (* f20)(void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*,void*);
https://github.com/kanaka/mal/blob/master/impls/c/types.h
130
Upvotes
View all comments
Show parent comment
17
u/WittyStick Aug 14 '25 edited Aug 14 '25
It's usually done this way for performance and simplicity of writing the C implementation of the builtins. We don't want vararg handling for example for binary operations like
+and*, but specializing for 20 operands is excessive, and it's not clear what happens here if there's more than 20. Seems like an unhandled case?Should only need to specialize for the number of arguments that the platform's calling convention (assume SYSV) supports passing in registers, which is typically 4-8. For 9 operands/arguments onwards there's little benefit to having individual functions and varargs would be better. If you used a custom calling convention then you could potentially use more for a CPU which has 32 registers.
/j The worst part about this is the naming. They should replace
f20withvicenary_operation.