proposal: spec: named check-handle pairs for error handling #31743
Labels
error-handling
Language & library change proposals that are about error handling.
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
After reading the proposed draft design I was very glad that there are some upcoming changes to the errorhandling in go.
I have also read a lot of similar proposals and you may argue this is a clone of some other proposal. My intention behind this is to offer my oppinion as a scriptingwise go-dependant engineer. Speed, readability and reusability are very much the things I am looking for.
The general idea behind
check
andhandle
will address the current issues with readability very well.The example in the draft design explains the usage of
check
andhandle
:This adresses readablility a lot, but repetitive code not by much:
Named dicts or structs are being used in various languages.
As an addition to
check
handle
I am now proposing - similar to labled handles - named pairs of these keywords. A named pair would have the following syntax:handle.<name>
check.<name>
Rewriting the given example you could then name the handle:
I know that that assigning to an attribute of a keyword like
handle.<name>
is unwanted by most and this needs to be adressed, but this code would be very readable and very reusable. There could also be standard definitions of named pairs likecheck.chain
,check.panic
, etc. or exported handles likehandle.Chain
orHandle.Chain
.I believe this would integrate very well with the current go language and would make at least my life easier.
Thanks for reading! I'm looking forward to the upcoming changes!
The text was updated successfully, but these errors were encountered: