Replies: 15 comments
-
Is there an actual use-case for target-typed new other than "it's cool so let's do it"? I am not a fan of adding more syntax to do things we can already do that is equally or more verbose than the current syntax. |
Beta Was this translation helpful? Give feedback.
-
IIRC it was mostly about enabling more succinct declarations in scenarios where |
Beta Was this translation helpful? Give feedback.
-
Benefit (minor, rare) does not seem worth the cost (duplicative syntax making code harder to read because its yet another thing to think about). |
Beta Was this translation helpful? Give feedback.
-
That looks like several syntax errors compounded on itself, is there something missing there (and what is the backtick for)? Did you mean this instead:
|
Beta Was this translation helpful? Give feedback.
-
It is kind of a counterpart to the default literal, but here you can actually instantiate the object. I'd expect some code style option to limit the usage. still, it's possible for a feature to get cut in the last minute, so please do share your concerns. |
Beta Was this translation helpful? Give feedback.
-
@alrz I appreciate the hard work you put in developing the feature- I just don't think there's enough benefit to it - or enough support for it for it. Roughly half of the votes are downvotes #100 (as we know a hundred votes on this board is a huge amount). |
Beta Was this translation helpful? Give feedback.
-
Wow, I would not have thought of |
Beta Was this translation helpful? Give feedback.
-
I think a big issue with it is readability. |
Beta Was this translation helpful? Give feedback.
-
@TheUnlocked A similar argument can be - and has been - made about the use of var and default, but the simple observation is that in most codebases they are only used where the type is already obvious. |
Beta Was this translation helpful? Give feedback.
-
Indeed, and i'm sure the IDE will have similar options there that exist for "var". i.e. code-style rules to say when a target-typed-new is allowed. So:
|
Beta Was this translation helpful? Give feedback.
-
I think the controversy around
private readonly Dictionary<(Foo foo, Bar bar), List<Baz>> bazByFooAndBar = new(); will be nice, being able to say: private readonly var bazByFooAndBar = new Dictionary<(Foo foo, Bar bar), List<Baz>>(); just feels like it fits in with current idioms more.
Target-typed new will be a nice addition, but it feels inelegant compared with alternatives. Thus the mixed reaction, I guess. |
Beta Was this translation helpful? Give feedback.
-
Except that the alternative for fields requires solving the Halting Problem. 🙃 |
Beta Was this translation helpful? Give feedback.
-
IMHO we should drop targeted new - too much pushback. If proposal is capable to gather almost equal number of up votes and down votes it should be dropped. There is a very large body of championed proposals which have far greater support and do not raise controversy which we should prioritize. Try not get syntactic sugar everywhere while you lack more fundamental capabilities in C#. Try to do generic numeric algorithms 😆 |
Beta Was this translation helpful? Give feedback.
-
I don't think it does. It requires the same cycle detection that we currently apply to consts, if I understand properly. Types are statically known and do not require running the problem. |
Beta Was this translation helpful? Give feedback.
-
If you can use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
https://github.com/dotnet/csharplang/blob/master/meetings/2018/LDM-2018-08-22.md
Agenda
Beta Was this translation helpful? Give feedback.
All reactions