Re:Go 1.18
by pharmakom on Tuesday March 15, 2022 @04:51PM
(#30691521)
Optionals without do notation will be a bad time.
[ Parent
| on HN ]
What's do notation?
I've used optionals in many languages, and this is the first I've heard of it. What else do you really need except map and... flatMap (aka `then` aka `and_then` aka `>>=` aka `bind`).
https://en.m.wikibooks.org/wiki/Haskell/do_notation
rough analogy: `await` replaces `.then()`, do-notation replaces `.flatMap()`
C# has had Nullable<T> for many years before it got stuff like ?. and ?? that mostly covers this, and it was, well, tolerable.
Re:Go 1.18
by BoorishBears on Tuesday March 15, 2022 @11:58PM
(#30695153)
Ergonomics sucked and a lot of people didn't use them (or even know they existed!) because ergonomics sucked
From my work experience at the time, it was used pretty heavily in new codebases.
Re:Go 1.18
by BoorishBears on Wednesday March 16, 2022 @12:00PM
(#30700466)
I mean the fact that they've been around since 2.0 but you saw it used heavily in new codebases says a lot doesn't it?
You misunderstood - I saw them in codebases that were new back when .NET 2.0 was new.
To be more precise, it was when .NET 3.5 was new (2008). That brought a lot of visibility to Nullable<T> because it was featured prominently in LINQ. But ?. didn't come until C# 6 (2014). I was wrong about ??, though - that one was added along with Nullable itself.