On Saturday, January 25, 2020 at 5:43:24 AM UTC-5, Brian Candler wrote: > > 1. When the issue of keyword arguments has come up before, usually someone > suggests passing a struct as the function argument. Did you try this? It > might be worth mentioning in your analysis, if only to give an example of > why it wasn't a good match. >
I'm picky about when I'll do that. I view putting a bunch of items in a structure as a promise to people reading the code that the structure isn't just a vacuous shim but captures an interesting chunk in the ontology of the program. "They're all arguments to this function" isn't interesting enough. 2. I notice some potential overlap between a couple of features you > mention. The first is map(f,x) for mapping a slice of arbitrary type > (incidentally it couldn't be called "map" for obvious reasons) The second > is using generator functions as ranges. > > It occurs to me that if you could initialize a slice from a generator > function, you'd have another way to achieve your map. The generator > function could also do filtering, making it more like a comprehension. > Perhaps. But map-over=sequence seems to me like a simpler primitive idea than "comprehension" and thus preferable. > 3. A generator function would have to maintain its own thread of execution > independent from the recipient - much like a goroutine. So this might end > up looking very similar to a function which stuffs values down a channel, > which is option 3 in the linked article > <https://ewencp.org/blog/golang-iterators/index.html>. > > The problem with garbage collection needs to be dealt with, which at the > simplest could be that the receiver closes the channel when done. Today > this would cause the sender to panic, so that would need to be dealt with - > perhaps some sort of "soft close". > And that's the insight that led be to the extension I proposed. I asked myself what the most natural way to pass out a soft close might be. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/04b5ee2c-40d0-4275-a53a-eaad9828c849%40googlegroups.com.