-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
エラー型による条件分岐をやりやすくする #403
Comments
|
ifによる値のチェックとは区別して
とか...? |
|
同意見 |
|
どちらかと言うと型表記の方に補集合を表す表記方が欲しいような? |
Rustの @f() {
let v = ...
v?.something // vがエラーならvを返し、そうでなければプロパティを評価
}
// トップレベルの場合
let v = ...
v? // vがエラーならCore:abort(v.name) 標準関数を追加するならこう?(大して楽にならないかも) Error:is(v) // vがエラーならtrue、そうでなければfalseを返す
Error:and(v, v2) // vがエラーならv2、そうでなければvを返す
Error:and_then(v, @(err) { ... }) // vがエラーなら関数を引数vで呼び出してその返値を返し、そうでなければvを返す |
|
どちらの記法のほうが平均的なコードが簡単になるんでしょうね…… 前者にした場合、後者の それか |
#237 はbug扱いになっているのでそっちを優先的に着手したいですね |
あと今のReturnをラッパーで包む実装方法だと中途returnの実装がかなり面倒になりそうな気がするんですよね |
毎回
if Core:type(v)!='error' ...
と書かなければならないのは不便なので、より簡単な書き方を考えます。今までの案
catch(v) {...}
if Core:is_ok(v) ...
補足
v ?? v2
(vがエラー型以外ならv、エラー型ならv2を返す)、?.
(エラー型ならチェーンしない?)も欲しいThe text was updated successfully, but these errors were encountered: