You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to propose a new language construction for block level checks, which can be useful im many situations
One application can be error handling, but the construction is not limited to this only
The new keyword will be in the form until [condition] { check expression } else { block code }
The condition will not be evaluated in declaration, but will be inserted after any expression with check keyword
The else clause is optional and will be executed if condition evaluate to false
varerrerror
{
check:=func(){if!(err==nil) {goto ELSE} }
err=someFunc; check();
goto END_BLOCK
ELSE:
// handleEND_BLOCK:
// code after until block
}
The construction can be used in complex checks
varrresultvarokbooluntilok&&r.Valid() {
checkv,ok:=someMap[key] // check inserted here with both ok and r.Valid() evaluated; if r is nil - it should panic as in *if* constructioncheckr.Update(someValue) // check evaluated herer.DoSomething() // no check evaluatedcheckr.NoChage() // check inserted here even both *ok* and *r* are not changed - this is programmer's responsibility
} else {
// handle situation
}
It can be used as loop as well
varaintuntila>1000&&a<2000 {
fori:=10;i<20;i++{
checka=i*i*i// this will break loop on i=13
}
}
The text was updated successfully, but these errors were encountered:
I would like to propose a new language construction for block level checks, which can be useful im many situations
One application can be error handling, but the construction is not limited to this only
The new keyword will be in the form
until [condition] { check expression } else { block code }
The condition will not be evaluated in declaration, but will be inserted after any expression with check keyword
The else clause is optional and will be executed if condition evaluate to false
Error handling can be expressed like this:
This roughly is equivalent to
The construction can be used in complex checks
It can be used as loop as well
The text was updated successfully, but these errors were encountered: