This comment shows a total misunderstanding of what functional programming is…
Re:Why your F# evangelism isn't working
by heywhatupboys on Wednesday May 31, 2023 @01:42AM
(#36134891)
While tongue in cheek, this is one if the OP in non-OP patterns that is used heavily for large projects in FP alike.
I'm not seeing that in the example, and I'm not even seeing anything very relevant to FP in the example either. I guess there isn't much mutation happening, and functions are called? But that's not what FP is.
Re:Why your F# evangelism isn't working
by tigershark on Wednesday May 31, 2023 @03:39AM
(#36135587)
This tells me that you never really looked at functional languages, not even used them.
The power of ADT, especially when using a comprehensive pattern matching expression, is pretty difficult to emulate in the OOP world without a ton of code.
But in this extremely simple case you just need a record.
let dogBar = {Name = “bar”; Age = 11; Friends = []}
let dogFoo = {Name = “foo”; Age = 12; Friends = [dogBar]}
printfn “%A” dogFoo.Friends
The advantage is that it’s immutable and it’s guaranteed to don’t have null in any fields.
C# only introduced records recently, while F# was born with them.
And C# still hasn’t got ADT because it’s missing the Union types as far as I remember.
oh... wait a minute