r/Compilers • u/mocompute • May 08 '26
Factoring out initial argument(s) from a group of function declarations: receiver blocks
https://mocompute.codeberg.page/item/2026/2026-05-08-tess-receiver-blocks.html
6
Upvotes
1
u/mocompute May 08 '26
This is not earth-shattering, but I think it's a nice quality of life feature that greatly enhances readability of C-style languages. When groups of functions share the same initial parameter(s), it can often be visually noisy to seem them all in a list, like in an API header or synopsis section.
'Receiver blocks' factor out the initial parameter(s), reducing visual clutter for the reader. And, there are some nice organisational properties that fall out, as a consequence.
While factoring out the first argument is pretty common, I haven't run across languages that allow arbitrary leading parameters to be factored out. The closest analogue I can think of is something like Common Lisp multi-methods, but receiver blocks are nothing like that.
1
u/rjmarten May 08 '26
The link doesn't appear to be working for me. Can you include the syntax you were thinking of here so we don't have to click a link?