News for hackers. Stuff that matters.
Re:The Next Step for Generics by londons_explore on Tuesday June 16, 2020 @04:16PM (#23543541)
I feel like such a class should either be part of the language, and part of language idioms etc, or it shouldn't be used.
Re:The Next Step for Generics by tomjen3 on Tuesday June 16, 2020 @04:26PM (#23543643)
Can you articulate why? it seems to me that 'feel' should not be part of the discussion.
Re:The Next Step for Generics by lenish on Tuesday June 16, 2020 @06:20PM (#23545001)
Not GP, but I've sometimes found libraries implementing similar concepts differently causing issues.

E.g.

    libraryA.Result struct {
        Err error
        Data SomeDataType
    }

    libraryB.Result struct {
        err string
        Data SomeDataType
    }
    func (r libraryB.Result) Error() string {
         return r.err
    }
Now you have two different implementations of the same fundamental idea, but they each require different handling. In Go, where many things simply return an error type in addition to whatever value(s), you would now have three different approaches to error handling to deal with as opposed to just whatever the language specified as the best practice.
Re:The Next Step for Generics by mrkeen on Wednesday June 17, 2020 @11:58AM (#23552895)
This is what interfaces are for.

Let your caller bring their own error type and instantiate your library code over that.

Re:The Next Step for Generics by juststeve on Tuesday June 16, 2020 @05:18PM (#23544282)
Not GP but:

It may frustrate coworkers who need to edit the code.

It adds another dependency into your workflow.