Discussion Thread: DIP 1033--Implicit Conversion of Expressions to Delegates--Final Review
Max Samukha
maxsamukha at gmail.com
Wed Nov 25 13:06:10 UTC 2020
On Friday, 20 November 2020 at 07:29:21 UTC, Mike Parker wrote:
> This is the discussion thread for the Final Review of DIP 1033,
> "Implicit Conversion of Expressions to Delegates":
>
> https://github.com/dlang/DIPs/blob/8e56fc593ece5c74f18b8eb68c3f9dcedf2396a7/DIPs/DIP1033.md
>
I don't quite understand this paragraph on "null":
"null implicitly converts directly to any delegate, but is not of
type T, so it will not be turned into a lambda. Again, this is
what is expected and is consistent with existing code."
What if T is another nullable type?
class C {
}
void foo(C delegate() c) {
C c2 = c(); // According to the DIP, segfaults immediately
instead of initializing c2 to null
}
void main() {
foo(null);
}
"null" implicitly converts to C and, therefore, should be
converted to "delegate() typeof(null){ return null; }" if we want
proper lazy semantics.
More information about the Digitalmars-d
mailing list