this post was submitted on 09 Jun 2024
229 points (79.6% liked)

> Greentext

7548 readers
643 users here now

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 8 points 5 months ago (1 children)

Null reference checking by the compiler is enabled by default in new C# projects.

C# doesn’t come with an option monad in its standard library, but its cooler sibling F# does.

[–] [email protected] 1 points 5 months ago (2 children)

You can also easily write your own option monad or use a tiny library that does.

[–] anus 2 points 5 months ago (1 children)

Good idea, then patch the whole standard library and dotmet framework and most popular libraries to use that tiny library

[–] [email protected] 0 points 5 months ago (1 children)

You don't need to use the same one. Just don't expose it publicly in libraries.

[–] anus 0 points 5 months ago (1 children)

This is the stupidest thing I've read all day

[–] [email protected] 0 points 5 months ago
[–] [email protected] -1 points 5 months ago

Yeah, 100%. I don't really recognize the complaint that "it isn't in the standard library" as being super valid. If you know what an option monad is and you want to use one, you can certainly create one. Lots of people don't know what it is and won't miss it, especially in this context since the option monad is a functional construct and C# is an objects-first language.