I think the idea of ‘field accessors’ is kind of scary. It is used all of the time in Java, but it happens there because Java has classes , so the generic can use a base class as a type - although most people do not do this for obvious reasons.
Go interfaces only have methods. If generics are based on interfaces, which they should be IMO, then you would need to add fields to interfaces. Poor choice IMO, and usually because the developer doesn’t spend enough time thinking about what the interface represents. given the color example, why would I have Red,Grren, Blue, Opacity all as fields? When if I had a GetColor() method, then I can use composition to blend colors on the fly, etc. With direct field access this is not possible. > On Sep 12, 2018, at 6:01 PM, Jonathan Amsterdam <jbamster...@gmail.com> wrote: > > Not to be snide, but we are looking for examples, not kinds of examples. Do > you know of actual code where this would benefit? > > For example, could field accessors improve the standard image and image/color > packages? > > On Wednesday, September 12, 2018 at 9:15:24 AM UTC-4, Mandolyte wrote: > On field accessors... > - Algorithms for X,Y points requiring them to be members of a struct type. > > - Algorithms to manipulate colors, requiring R,G, and B to be members. > > In an image processing library with its own rich set of struct types, such > accessors would prove productive. > > Are these the kind of examples you meant? > > > > > > -- > 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 > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- 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. For more options, visit https://groups.google.com/d/optout.