3 ms·
With the advent of generics, there’s no reason we can’t get libraries that wrap common objects. As a thought experiment, I could see Optionals, Named Channels,
by vineyardmike 2y ago
With the advent of generics, there’s no reason we can’t get libraries that wrap common objects.
As a thought experiment, I could see Optionals, Named Channels, Collections etc being implemented in some common but non-stdlib library. Of course now we’ve recreated all those languages people hate when they talk about go… but those features exist for a reason.
- tptacek 2y agoI don't think you're getting useful optionals without matching.
- vineyardmike 2y agoI’d take Java-style optionals but yea matching would be welcome to me.
- DylanSp 2y agoThere are type switch statements, at least, and libraries like https://github.com/phelmkamp/valor https://github.com/phelmkamp/valor can use them to provide more concise abstractions. The really frustrating thing is that interfaces can't have methods that introduce new type parameters, so we're stuck with standalone functions like `optional.Map(optionalFoo, barFunc)` instead of `optionalFoo.map(barFunc)`>