Re: [go-nuts] Idea extending xerror.As

2021-09-21 Thread David Finkel
On Mon, Sep 20, 2021 at 10:52 PM Andrey T. wrote: > > ... or, to put a crazy idea out there, we need to ask for extension of > switch statement to support (v, err) tuples for a case argument... That's not a particularly crazy idea. It's just one that's unlikely to make it through with one use-c

Re: [go-nuts] Idea extending xerror.As

2021-09-20 Thread Andrey T.
... or, to put a crazy idea out there, we need to ask for extension of switch statement to support (v, err) tuples for a case argument... On Sunday, September 19, 2021 at 3:43:36 PM UTC-6 david@gmail.com wrote: > On Sun, Sep 19, 2021 at 5:19 PM roger peppe wrote: > >> In some ways, the exis

Re: [go-nuts] Idea extending xerror.As

2021-09-19 Thread David Finkel
On Sun, Sep 19, 2021 at 5:19 PM roger peppe wrote: > In some ways, the existing API is arguably more ergonomic than the > originally proposed generic version, as it's possible to use `errors.As` in > a switch statement (eg to test several possible types of error) which isn't > possible with the m

Re: [go-nuts] Idea extending xerror.As

2021-09-19 Thread roger peppe
In some ways, the existing API is arguably more ergonomic than the originally proposed generic version, as it's possible to use `errors.As` in a switch statement (eg to test several possible types of error) which isn't possible with the multi-return `As` variant. A minor variant of the existing AP

Re: [go-nuts] Idea extending xerror.As

2021-09-19 Thread David Finkel
On Sun, Sep 19, 2021 at 4:02 PM David Finkel wrote: > You might be interested in the original draft proposal for errors.As: > > https://go.googlesource.com/proposal/+/master/design/go2draft-error-inspection.md#the-is-and-as-functions > > In particular, it originally specified that errors.As would

Re: [go-nuts] Idea extending xerror.As

2021-09-19 Thread David Finkel
You might be interested in the original draft proposal for errors.As: https://go.googlesource.com/proposal/+/master/design/go2draft-error-inspection.md#the-is-and-as-functions In particular, it originally specified that errors.As would take a type-parameter. (the version of generics that was propo