3 ms·
That doesn't quite work, as the maybe pattern also implies a chaining operation (flatMap), which is impossible to implement without generics
by spion 12y ago
That doesn't quite work, as the maybe pattern also implies a chaining operation (flatMap), which is impossible to implement without generics
- falcolas 12y agoYou can still chain, you just have to do type conversion to and from the interface{} type. It's not pretty (and not in broad adoption), but neither is it impossible.
- spion 12y agoThat defeats the point of having a type system (casting is as error prone as forgetting to check errors). Also it doesn't allow for the use of already defined functions to do the transformations, (e.g. `maybe.flatMap(existingFn).flatMap(otherFn)` wont ever work, new closures will have to be defined that do casts before calling the existing functions). So basically, its just-as-error-prone and just-as-tedious as checking error codes but in a different way. Both benefits of the pattern are gone. Given this, I don't think that the word "impossible" is a stretch at all (not having any of the benefits of the pattern = not implementing the pattern)