Target typed new expressions for D?
Imperatorn
johan_forsberg_86 at hotmail.com
Fri Apr 30 16:24:34 UTC 2021
On Friday, 30 April 2021 at 16:20:13 UTC, sighoya wrote:
> Relates to the following:
>
> https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/#target-typed-new-expressions
>
> What do you think about?
>
> I like it more than `auto` inference. You have an explicit
> invariant, and the constructor takes the invariant into account
> for value construction.
>
> I think, however, that using `new` in D isn't possible anymore,
> maybe some different keyword.
>
> Is this at all possible with templates now or did we suffer
> from missing return type deduction?
Lol, that's kinda cute. Maybe you could even omit the type and
let the compiler match, like auto p = new(2,5) 😁 (p is Point for
example),I would never write code like that tho.
I don't know how useful that is tho, even in C# like, you already
get completion for the type so..
More information about the Digitalmars-d
mailing list