Very in-depth and interesting. Although I agree with most of the points, I think a better use of interfaces would address some of your concerns, and have more maintainable code.
Whenever I see a type switch it screams to me “use an interface and restructure. “ >> On Jan 25, 2020, at 4:43 AM, Brian Candler <b.cand...@pobox.com> wrote: > > Very insightful. > > I am relatively new to go, but I would like to make a few observations. > > 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. > > 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. > > 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. > > 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". > -- > 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/fdd4882f-0c17-42f2-b301-ab65e5ce08a7%40googlegroups.com. -- 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/C1720736-D9CC-4D98-9D54-5EF69CF1B9CD%40ix.netcom.com.