3 ms·
This approach feels quite invasive compared to adding a standard interface that `range` accepts. Some discussions have happened before, eg https://github.com/go
by kevmo314 3y ago
This approach feels quite invasive compared to adding a standard interface that `range` accepts. Some discussions have happened before, eg https://github.com/golang/go/discussions/54245 https://github.com/golang/go/discussions/54245
A standard interface feels a cleaner than these nested callback functions.
- deleted 3y ago[deleted]
- christophilus 3y agoThe function-based approach is kind of nice because you can use defer for cleanup, and you don’t have to write an entire struct and track state via props, etc. I kind of like this proposal.
- earthboundkid 3y agoThe interface version is nicer for consumers in a world where you can’t range over a function, but the function version is way easier to write, so once you can range over functions, the advantages of the interface versions mostly go away.