On Mon, Mar 23, 2020 at 10:28 AM Adrian Ratnapala <
adrian.ratnap...@gmail.com> wrote:

> I think this is the classic dynamic vs. static typing trade-off.


I don't fully agree here - I think it's perfectly possible to have all of
the flexibility and all of the static type-checking. I'm having trouble
putting it into words exactly, but I think both Java's subtype based
checked exceptions and Haskell's HM type inference are approaches to
achieve that. Of course, both have their own downsides, so you can't fully
escape the tradeoff. But personally, I still kind of feel that it would've
been possible to add variance to `func()` and `interface` type constructors
and get a pretty decent way to solve these problems with static type
checking. But it's not actually trivial, so I won't complain about it :)

So to turn this discussion into something actionable: should this
> advice be added into the documentation?  And if so, where (in package
> fmt or errors)?
>

I don't think there is broad concensus on this in the community. At least
that was my impression whenever I talked about it with people at
conferences and meetups. Even worse, I don't even think there is a phrasing
of this advice that is both sufficiently broad to be applicable and
sufficiently specific to be agreeable *to myself*. Like, there is a reason
I chose to mention examples, instead of coming up with a rule. To me, at
least, API design is hard and kind of an art form. I sort of scoff at sage
advice about it, because as far as I can tell, all of it has exceptions and
sometimes it feels that it has more exceptions than regular cases :)

Without consensus, I don't think there will be more "official" advice than
what you've already mentioned in your original message :) And even that is
pretty clear:

> There is no single answer to this question; it depends on the context in
which the new error is created.

Lots of programers will assume that because %w is new, then it must be
> the Go team's recommended "best practice".  I think I was unconciously
> thinking that until I read the blog post.
>
>
>
> --
> Adrian Ratnapala
>

-- 
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/CAEkBMfHb8E5SJEKd%2B529PnQGLFDOsGAV%2B_-KnWxU%3DxoyazeQVw%40mail.gmail.com.

Reply via email to