Source
- URL: https://x.com/vkrajacic/status/1749816169736073295
- Author: Vjekoslav Krajačić (@vkrajacic)
- Posted: 2024-01-23 15:27:39
Thread
1/ @vkrajacic
C macro approach to using optional / default / named function params, using struct designated initializers.
Mandatory values are passed first as standard function params (rect in the example).
Especially useful when a zero value can be made a valid value.
Branches: 2024-01-23-alurmanc-shouldnt-it-be-transformarguments-parameters-are, 2024-01-23-DanielcHooper-nice-when-you-combine-this-with-all-the-other, 2024-01-23-endu06-how-does-default-work-do-variable-args-bypass, 2024-01-23-luis_reyes_x-very-cool-designated-initializers-is-one-thing-i, 2024-01-24-falco_girgis-the-only-problem-here-is-that-you-cannot-do-this, 2025-08-13-peach2k2-really-cool-but-this-doesnt-mean-c-is-a-good-or, 2025-08-13-heyitsvaishnav-this-is-soo-good-i-did-it-in-typescript-as-well, 2025-08-13-JLakness-c-functor-method, 2025-08-14-EskilSteenberg-am-i-the-only-one-who-thinks-this-is-terrible-its, 2025-08-14-quantized_state-instantly-rewriting-everything
2/ @pATjako
@vkrajacic
I started experimenting with that in my imgui as well, it is kinda neat, also you can make the same code work for C & C++ (with some limitation in argument ordering)