3 ms·
Postfix is only superior when you have lots of things to chain. C doesn't have any chaining at all. f(g(x)) is just as good as f(g(x))
by 3836293648 2y ago
Postfix is only superior when you have lots of things to chain. C doesn't have any chaining at all. f(g(x)) is just as good as f(g(x))
- card_zero 2y agoGotta escape those asterisks so you don't output italics. f(*g(*x)) is just as good as f(g(x*)*) Hmm, function names go before parentheses, that looks like a good reason for dereferencing to be prefix too, otherwise they end up a long way apart. But in the back of mind I'm thinking "semantics cause pointless fussy arguments, all code is ugly, let's stop programming in text somehow".
- 3836293648 2y agoOh yeah, forgot HN supported some markdown. But this is literally not semantics. Semantics is everything of value, this is just syntax.
- card_zero 2y agoSorry, yes, syntax. I was equating it to "purely semantic argument", arguing about the meaning of words. Here about it's where to put symbols.
- dfawcus 2y agoOne is able to chain calls in C via: x()->g()->f(); At least one person at Bell Labs historically used that scheme for some graphics program. All it requires is that the function returns a pointer to a struct which itself contains function pointers. C also allows the dot form if you really want it: x().g().f() Simply by returning structs, and for all compilers that I know if, such end up using a hidden pointers to structs. Now to make it a bit more usable, one needs a bit of planning so that either of these can be done: x(&x_out).g(&g_out, x_out).f(&f_out, g_out); x(&x_out)->g(&g_out, x_out)->f(&f_out, g_out); (I'd suggest the latter is now the more readable of the two). Where there is a VFT in each of the xxx_out structures, and the calls simply returns the VFT, while the whole abstraction is stored/returned via the out arguments.