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
@gafter, I'm assigning this to you in the hope you can give me early feedback on my initial thoughts on how to write a proposal for this feature, so I can get started. Thanks in advance! Of course, input from other members is also welcome.
The "Detailed design" part of the proposal suggests introducing a new kind of expression, the default literal. At a first/second read, that suggests a separate section in expressions.md. However, the "Summary" part of the proposal states
The target-typed default feature is a shorter form variation of the default(T) operator, which allows the type to be omitted. Its type is inferred by target-typing instead. Aside from that, it behaves like default(T).
Here's my thinking:
Rather than add a new section, what we already have in 12.7.15 Default value expressions can be extended to handle this new spelling of a default value. For example, the existing grammar could be extended thus:
I think I'm most in favour of the last idea, giving them different names. But it's a weakly-held position, from someone who's really not a grammar expert.
@gafter, I'm assigning this to you in the hope you can give me early feedback on my initial thoughts on how to write a proposal for this feature, so I can get started. Thanks in advance! Of course, input from other members is also welcome.
Proposal https://github.com/dotnet/csharplang/blob/standard-proposals/proposals/csharp-7.1/target-typed-default.md allows the use of
default
on its own (rather thandefault(T)
) in contexts where the type can be inferred.The "Detailed design" part of the proposal suggests introducing a new kind of expression, the default literal. At a first/second read, that suggests a separate section in expressions.md. However, the "Summary" part of the proposal states
Here's my thinking:
Rather than add a new section, what we already have in 12.7.15 Default value expressions can be extended to handle this new spelling of a default value. For example, the existing grammar could be extended thus:
rather than the more succinct
[By adding the grammatically unnecessary rule default_literal, we give a name to that alternative that we can refer to in the narrative.]
That said, I see an advantage to also having a name for the existing alternative; perhaps we could do something like the following instead:
Using this approach, I think the changes to this section are minimal.
The only other edits I see are
default == default
(if that is not already covered)I'll write some tests to figure out what support is given by the
is
andas
operators.The text was updated successfully, but these errors were encountered: