3 ms·
I agree that there are semantic issues with pointers, but my point was to illustrate that you need sum types in Go to get any real benefit out of an Option type
by weberc2 6y ago
I agree that there are semantic issues with pointers, but my point was to illustrate that you need sum types in Go to get any real benefit out of an Option type. If you need an option type and you aren't content with a pointer, you can use `(T, bool)`, but this is still a far cry from a real Option type.
- alkonaut 6y agoI use Option<T> types very happily in C# without sum types. Most of what would be pattern matching can be done with just methods. Car c = maybeCar.GetValueOr(CreateCar()) // inline fallback maybeDog.Do(d => b.Bark()) // only performs call if present Sailboat s = mybeBoat.As<SailBoat>() // none unless of correct subtype And so on. With nullable reference types C# now has a builtin alternative to this, but it has worked we’ll for many years.