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
With non-nullable types, we propose to make the null aware operators short-circuiting. I believe that at least some proposals for the extension method patterns would allow you to write the following extension:
And I believe that the proposals would match this extension to e.toDefault() when e has type int or int?. So the question is, what are the semantics of:
(nullasdouble?)?.toInt().toDefault()
In particular, does this desugar using ordinary method desugaring as:
let tmp = (nullasdouble?) in (tmp ==null) ?null:toDefault(tmp.toInt())
or do we treat extension methods that apply to null differently and desugar as:
let tmp = (nullasdouble?) intoDefault(tmp ==null?null: tmp.toInt())
We should definitely make the null-aware operator short-circuiting.
We should also make extension methods work just like normal methods, to as great an extend as absolutely possible.
That means that
(nullasdouble?)?.toInt().toDefault()
would then rewrite to:
let tmp =nullasdouble?in tmp ==null?null: tmp.toInt().toDefault();
The type of tmp.toInt() is int, so it matches the NullInt extension's type pattern,
and it ends up as:
let tmp =nullasdouble?in tmp ==null?null:NullInt.toDefault(tmp.toInt());
With non-nullable types, we propose to make the null aware operators short-circuiting. I believe that at least some proposals for the extension method patterns would allow you to write the following extension:
And I believe that the proposals would match this extension to
e.toDefault()
whene
has typeint
orint?
. So the question is, what are the semantics of:In particular, does this desugar using ordinary method desugaring as:
or do we treat extension methods that apply to null differently and desugar as:
cc @munificent
The text was updated successfully, but these errors were encountered: