|
Number one on the list of future C# features is Nullable Reference Types. But also on the table are enhancements to pattern matching, array slicing, asynchronous iterators, default interface methods, and possibly even records. Even #er?
Seems more than a bit of a repeat, but it's all in one spot, and there were a couple I don't remember seeing before.
|
|
|
|
|
For the first time, I think that some of these extensions are, at least as presented, getting it wrong. Semantically, many are great, but syntactically they seem to have opted for the least readable form possible...
return person switch
{
Professor p => $"Dr. {p.LastName}",
Student s => $"{s.FirstName} {s.LastName} ({s.Level})",
_ => $"{person.FirstName} {person.LastName}"
};
Seems pretty ugly. As is...
case Student ( var fn, _, "Cambell", var (_, _, ln) ) p : return $"{fn} is enrolled in {ln}’s class";
Indexing from the end of a string/array...
var lastCharacter = myString[^1];
I appreciate the features being proposed and use them in other languages, but really hope they manage to make these a bit more readable.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
(disclaimer. I know near zero C#, especially at this level).
Can you ELI5 the first two examples ?
Seriously, can you ? I've got no clue what I'm supposed to look at.
I'd rather be phishing!
|
|
|
|
|
Example 1:
C# 8:
return person switch
{
Professor p => $"Dr. {p.LastName}",
Student s => $"{s.FirstName} {s.LastName} ({s.Level})",
_ => $"{person.FirstName} {person.LastName}"
}; C# 7:
switch (person)
{
case Professor p:
{
return $"Dr. {p.LastName}";
}
case Student s:
{
return $"{s.FirstName} {s.LastName} ({s.Level})";
}
default:
{
return $"{person.FirstName} {person.LastName}";
}
} C# 6:
Professor p = person as Professor;
if (p != null)
{
return string.Format("Dr. {0}", p.LastName);
}
Student s = person as Student;
if (s != null)
{
return string.Format("{0} {1} ({2})", s.FirstName, s.LastName, s.Level);
}
return string.Format("{0} {1}", person.FirstName, person.LastName);
Example 2:
C# 8:
case Student ( var fn, _, "Cambell", var (_, _, ln) ) p:
{
return $"{fn} is enrolled in {ln}’s class";
} C# 7:
case Student s when s.LastName == "Cambell":
{
return $"{s.FirstName} is enrolled in {s.Professor.LastName}’s class";
} C# 6:
Student s = person as Student;
if (s != null && s.LastName = "Cambell")
{
return string.Format("{0} is enrolled in {1}’s class", s.FirstName, s.Professor.LastName);
}
Personally, I prefer the C# 7 version. But I can see the "switch expression" appealing to F# fans.
Match expressions (F#) | Microsoft Docs[^]
The recursive pattern (example 2) just looks horrible to me.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 22-May-18 15:08pm.
|
|
|
|
|
Crikey, just shoot me !!!
I'd rather be phishing!
|
|
|
|
|
Oddly, I'm perfectly at home with similar features in Haskell and Rust, but somehow they just don't seem to sit well with the rest of C#'s syntax.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
'Silver Star with Bronze Clusters' awarded for exceptional bravery in the face of acronym-fire
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Being a developer these days is both good and bad. There are a lot of jobs available out there but there is a lot of competition too. 'What's with all those semi-colons?'
|
|
|
|
|
Treasury Secretary Steven Mnuchin urged the Justice Department to review the power that large technology firms such as Google have over the American economy, the latest U.S. official to back antitrust scrutiny of the industry. Have you now, or have you ever been, a company that the government can't understand?
|
|
|
|
|
Our tech requirements are stressing today's fashion. Fortunately, a new generation of designers is looking to the future of tech-capable clothing. "'Cause every girl crazy 'bout a sharp dressed man" (and vice versa)
|
|
|
|
|
New evidence in favor of a discrete form of data storage could change the way we understand the brain and the devices we build to interface with it. Mine's formatted using FAT
As many of you have suspected.
|
|
|
|
|
The brain stores information?
|
|
|
|
|
Kent Sharkey wrote: Mine's formatted using FAT
Mmmm! Donuts!
|
|
|
|
|
The problem with std::optional is that we lose information about errors. The function returns a value or something empty, so you cannot tell what went wrong. Only one is optional
|
|
|
|
|
That's fine - it should be used in limited circumstances where the error is obvious. For example, parsing an integer from a string will either recognise an integer or not - there really is not much more useful to say.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
The vast majority of botnet malware infections last under a day, according to a Fortinet report released last week —the Q1 2018 Threat Landscape Report. Bed rest and plenty of fluids recommended
|
|
|
|
|
Test reveals that the magic space unicorns pushing the EM-drive are magnetic fields. The "paradox" is only a conflict between reality and your feeling of what reality "ought to be"
|
|
|
|
|
The company has posted the source code for both the material that builds the Autopilot system image as well as the kernels for the Autopilot boards and the NVIDIA Tegra-based infotainment system used in the Model S and Model X. Now you can build your own, and save a bundle!
Or more likely: someone will find a flaw and hack into people's dash
|
|
|
|
|
[^]Quote: An “infrasound haptic” flooring system will carry bass sounds through the floor, allowing guests to experience the music under their feet.
A “beamformed” sound system will deliver remarkably clear acoustics, thanks to thousands of tiny speakers embedded in the building’s walls.
Technicians will be able to capture and present super-resolution video with a specially designed camera system that captures and stitches together 360-degree-by-360-degree footage at 2 gigabytes per second.
More than 200 resort executives and entertainment specialists got their first immersion into the audio and visual world of MSG Sphere at an invitation-only demonstration Friday at the Las Vegas Sands Corp. hangar at McCarran International Airport.
Madison Square Garden’s planned MSG Sphere will be a 360-feet-tall and 500-feet-wide concert venue
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
I could say something about how this will enhance Las Vegas' other revenue stream (not gambling, not drive through marriage chapels.)
|
|
|
|
|
Marc Clifton wrote: Las Vegas' other revenue stream (not gambling, not drive through marriage chapels.) You mean the swarms of tourists who come to make selfies against a barren desert backdrop ?
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
BillWoodruff quoted: MSG Sphere will be a 360-feet-tall and 500-feet-wide concert venue
When I went o school, a sphere had to be the same height as its width. But I suppose 'The MSG Ovoid' would not sound as good as you might think it is an egg enhanced by monosodium glutamate.
|
|
|
|
|
What else can you expect from Americans? Even their football isn't spherical!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
My guess is that "MSG Spherical Cap" just doesn't sound as catchy.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Paleotronic was lucky enough to be given the chance to have a chat with Apple co-founder and engineer-extraordinare Steve Wozniak, who gave us a personal look into the development of the Disk II. Popping around to the shop for a thumb drive too easy?
My eyes hurt after reading that page.
|
|
|
|