Hacker News new | ask | show | jobs
by silisili 1066 days ago
Perhaps language change was bad wording, I guess I meant paradigm change encouraging? Just look at this func signature and first line...

> func Pull[V any](push func(yield func(V) bool)) (pull func() (V, bool), stop func()) {

> copush := func(more bool, yield func(V) bool) V {

The main power of Go to me was always quickly being able to read and understand code. This type of coding has a lot of cognitive load to a reader, I feel.

1 comments

The implementation of Pull may be a bit mysterious to the casual reader, but its usage seems clear enough to me from the function signature. Even without reading the docs I think it’s easy to guess what yield, pull, and stop should do (and how to implement yield). That’s what matters, imo.

Fwiw if you look at the source of some other idiomatic standard library functions you may find their implementation is of similar complexity. That’s the nature of good abstractions, though, they should make tricky things easy to use.