Click here to Skip to main content
15,388,892 members
Home / Discussions / C#
   

C#

 
GeneralRe: About records Pin
Super Lloyd3-Jan-22 20:33
MemberSuper Lloyd3-Jan-22 20:33 
GeneralRe: About records Pin
Super Lloyd3-Jan-22 21:07
MemberSuper Lloyd3-Jan-22 21:07 
GeneralRe: About records Pin
BillWoodruff4-Jan-22 4:49
mveBillWoodruff4-Jan-22 4:49 
AnswerRe: About records Pin
Richard Deeming3-Jan-22 23:14
mveRichard Deeming3-Jan-22 23:14 
GeneralRe: About records Pin
Super Lloyd3-Jan-22 23:17
MemberSuper Lloyd3-Jan-22 23:17 
AnswerRe: About records Pin
BillWoodruff4-Jan-22 5:38
mveBillWoodruff4-Jan-22 5:38 
GeneralRe: About records Pin
Super Lloyd4-Jan-22 5:49
MemberSuper Lloyd4-Jan-22 5:49 
AnswerRe: About records Pin
endo funk7-Jan-22 1:55
Memberendo funk7-Jan-22 1:55 
That's the point of many functional building blocks; they're simple by design; expressly so.

In contrast to reference types; a value type, like a record, avoids the guess work that's inherent with state management. On the surface that may appear pointless; why would we want something less powerful and similarly not mutable?

Simply said it's difficult to impossible to mathematically reason about a type whose state is in flux. The functional programming approach is always to build parts that are as simple as they can be; because the more simplistic something is, the greater its potential for composition, and the easier for us to mathematically reason about the outcome of that composition.

Functionally constructed applications are a composition of many simplistic parts:
- their simplicity is what simplifies reasoning
- whereas their ease of composition, is what enables the power.

As example:
The lack of flux in functional programming is what typically makes functional code far easier to multithread than OOP code; because.. for example: all the contention that's typical to referencing is avoided as a default -- by explicit design there is no likelihood for data race conditions between functionally code threads.

As to why "with" is only available to records?
It's because records, unlike reference types, are by design immutable; so without something like "with"; changing values would be far more difficult for record types, and there typically would be no standard approach that everyone could rely upon. With reference types; the standard is; getters and setters. "with" is essentially the setter standard for record types.

Side note:
"With" design is not an entirely new concept; it for the most part is a very simplistic introduction of Functional Optics (e.g. Lenses) to C#. Many of these more complex functional optics can be constructed in C#; although a lot of boiler plate is still required to take full advantage of it. Hopefully this is a gap that could be covered in a future C# release i.e. automatic code generation of functional optics for record types.
GeneralRe: About records Pin
Super Lloyd7-Jan-22 8:49
MemberSuper Lloyd7-Jan-22 8:49 
GeneralRe: About records Pin
endo funk7-Jan-22 10:39
Memberendo funk7-Jan-22 10:39 
QuestionBlazor: IEnumerable ElementAt Pin
chrisb15162-Jan-22 23:49
Memberchrisb15162-Jan-22 23:49 
AnswerRe: Blazor: IEnumerable ElementAt Pin
#realJSOP3-Jan-22 2:16
mva#realJSOP3-Jan-22 2:16 
GeneralRe: Blazor: IEnumerable ElementAt Pin
chrisb15163-Jan-22 10:11
Memberchrisb15163-Jan-22 10:11 
GeneralRe: Blazor: IEnumerable ElementAt Pin
#realJSOP3-Jan-22 22:39
mva#realJSOP3-Jan-22 22:39 
AnswerRe: Blazor: IEnumerable ElementAt Pin
OriginalGriff3-Jan-22 2:23
mveOriginalGriff3-Jan-22 2:23 
AnswerRe: Blazor: IEnumerable ElementAt Pin
Gerry Schmitz3-Jan-22 5:51
mveGerry Schmitz3-Jan-22 5:51 
GeneralRe: Blazor: IEnumerable ElementAt Pin
OriginalGriff3-Jan-22 6:28
mveOriginalGriff3-Jan-22 6:28 
Questioncausing the computer to freeze Pin
Calin Cali2-Jan-22 4:01
MemberCalin Cali2-Jan-22 4:01 
AnswerRe: causing the computer to freeze Pin
Gerry Schmitz2-Jan-22 4:42
mveGerry Schmitz2-Jan-22 4:42 
GeneralRe: causing the computer to freeze Pin
Calin Cali3-Jan-22 8:11
MemberCalin Cali3-Jan-22 8:11 
AnswerRe: causing the computer to freeze Pin
OriginalGriff2-Jan-22 6:29
mveOriginalGriff2-Jan-22 6:29 
GeneralRe: causing the computer to freeze Pin
Calin Cali3-Jan-22 6:13
MemberCalin Cali3-Jan-22 6:13 
GeneralRe: causing the computer to freeze Pin
OriginalGriff3-Jan-22 6:45
mveOriginalGriff3-Jan-22 6:45 
AnswerRe: causing the computer to freeze Pin
#realJSOP2-Jan-22 23:53
mva#realJSOP2-Jan-22 23:53 
AnswerRe: causing the computer to freeze Pin
0x01AA5-Jan-22 4:40
professional0x01AA5-Jan-22 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.