Go’s io package works so well because interfaces are implicit and lightweight.
In C, you can mimic the shape with function pointers, but you lose a lot of the ergonomics and safety. Curious how far you can push composability before it becomes too cumbersome to use in practice.
A nit on the use of *: in lots of places there are "int* foo" and so on, but in C it's traditional to have "int *foo" since "int* foo, bar" looks like foo & bar are pointers, but they are not, bar is an int, while "int *foo, bar" suggests the interpretation that the compiler will make.
Go’s io package works so well because interfaces are implicit and lightweight.
In C, you can mimic the shape with function pointers, but you lose a lot of the ergonomics and safety. Curious how far you can push composability before it becomes too cumbersome to use in practice.
A nit on the use of *: in lots of places there are "int* foo" and so on, but in C it's traditional to have "int *foo" since "int* foo, bar" looks like foo & bar are pointers, but they are not, bar is an int, while "int *foo, bar" suggests the interpretation that the compiler will make.
Good catch—C’s declarator syntax can definitely be misleading there, especially with multiple variables in one line.