Probable C# 6.0 features
Idan Arye
GenericNPC at gmail.com
Tue Dec 10 15:21:12 PST 2013
On Tuesday, 10 December 2013 at 18:58:01 UTC, Suliman wrote:
> Maybe it would be possible to get some good idea from next
> version of C#
> It's only ideas about next version, but new future maybe next:
> http://damieng.com/blog/2013/12/09/probable-c-6-0-features-illustrated
I really like the "Inline declarations for out params"
feature(number 9). The example given in the article is kind of
lame, but combined with conditionals it can be a really big
improvement:
if(int.TryParse(a,out int b)){
//some code that uses `b`
}
If this works as I expect it to work, `b` will only be defined in
the scope of the `if` statement. If we had to declare `b`
beforehand, it would have polluted the surrounding scope, when
not only we don't use it after the `if` but it doesn't have a
meaningful value if `TryParse` yields `false`!
Also - it allows using type inference when declaring those out
parameters, which is always a good thing.
This feature can be compared to D's declare-in-if syntax, but
they are not equivalent. Consider:
if(int b=a.tryParse!int()){
//some code that uses `b`
}
if `a` is "0" we won't enter the then-clause even though we
managed to parse. This is why we don't have this `tryParse`
function in D...
More information about the Digitalmars-d
mailing list