I don't think I've ever seen a case where I wished for that feature.
All the other things - tuples, anonymous out vars, pattern matching - I've found myself wanting quite often.
11–20 of 278 posts
I don't think I've ever seen a case where I wished for that feature.
All the other things - tuples, anonymous out vars, pattern matching - I've found myself wanting quite often.
Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. It's great to finally have tuples, but the c/java style syntax is showing it's age compared to something like scala which has return type declarations at the end, which I find much more readable. Literal improvements will be a godsend for writing database migrations. Ref returns and locals look li…
Can you elaborate on this; both how it helps and why you're using C# for database migrations?
Like everything except "Ref returns and locals". I don't think I've ever seen a case where I wished for that feature. All the other things - tuples, anonymous out vars, pattern matching - I've found myself wanting quite often.
Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. It's great to finally have tuples, but the c/java style syntax is showing it's age compared to something like scala which has return type declarations at the end, which I find much more readable. Literal improvements will be a godsend for writing database migrations. Ref returns and locals look li…
IEnumerable GetStudents(SqlCommand cmd)
{
var rdr = cmd.ExecuteReader(); //select * from student left join courses on...
var memo = new Dictionary(); //Completion lets us add courses to a student
while(rdr.Read())
{
if(!memo.TryGetValue(rdr.GetInt32("student_id"), var out complete)
memo.Add(new Student(rdr out complete).ID, complete);
complete.AddCourse(rdr); //might be a no-op
}
return from kv in memo select kv.Value.Student; //each student object is unmodifiable.
}In the .Net/VisualStudio world, the language tooling (Intelisense, visual drawing XAML & WinForms, etc) became as important as the language semantics or the availability of frameworks and documentation.
A long ago there was a fad, known as CASE (Computer Aided Software Engineering) that advocated doing on programming what CAD did to other engineering. It seems that were finally getting there.
It looks like they've added a lot of rope to hang ourselves with typos. int myvar, I; foo(out int mvar); // oops, not myvar; maybe caused by a refactor? bar(out *); // oops, not I; was up too late coding And so on. Things like this would be easily missed when reading code at-a-glance, and it's this sort of bug that arises often in languages that allow implicit declaration of variants.
R# should warn "unused variable myvar" on the first one. You'll get a compiler error if you try and use `I` uninitialized. Not saying you're wrong, just having trouble getting worried about this. You can make typos now: int x, y; foo(out x, out x); // oops, not y; was up too late coding
Sure, you can make typos now, but these changes expand the possibilities of errors arising from typos or incomplete refactoring; while reducing the discoverability of the issue at-a-glance.
Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. It's great to finally have tuples, but the c/java style syntax is showing it's age compared to something like scala which has return type declarations at the end, which I find much more readable. Literal improvements will be a godsend for writing database migrations. Ref returns and locals look li…
> Literal improvements will be a godsend for writing database migrations. Can you elaborate on this; both how it helps and why you're using C# for database migrations?
Each migration gets a number, typically time encoded. If I was to write one now it would have the attribute [Migration(201608251157)]. With the new literals this will become [Migration(20160825_1157)], amazing how much readability a single underscore can make.
Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. It's great to finally have tuples, but the c/java style syntax is showing it's age compared to something like scala which has return type declarations at the end, which I find much more readable. Literal improvements will be a godsend for writing database migrations. Ref returns and locals look li…
> it's age compared to something like scala which has return type declarations at the end, which I find much more readable. Scala or .... VB.net!
1. Regex expressions just like Regexp in JS:
/^\s+$/.IsMatch(" "); // or
Regex r = /^\s+$/;
2. DateTime expressions, similar to regex, something like: DateTime clockTowerLightning = #1955/11/12 10:04PM#;It looks like they've added a lot of rope to hang ourselves with typos. int myvar, I; foo(out int mvar); // oops, not myvar; maybe caused by a refactor? bar(out *); // oops, not I; was up too late coding And so on. Things like this would be easily missed when reading code at-a-glance, and it's this sort of bug that arises often in languages that allow implicit declaration of variants.
This should fail to compile, it's the equivalent of declaring a variable twice int the same scope.