This is a suggestion to make error handling more explicit than what's described in the official proposal.
An error handler is declared as:
handle err { return err }
This declares err as an error variable, and an err_handler as a
This is a suggestion to make error handling more explicit than what's described in the official proposal.
An error handler is declared as:
handle err { return err }
This declares err as an error variable, and an err_handler as a
v2:
This started as a thought experiment after I read the Go generics and contracts proposal. The original proposal is powerful enough to specify precise type properties from the point of the generic implementor, however constraints such as "type T must support operator <" is over-specific in a language where < cannot be redefined. Such a constraints means "T must be numeric or string". So this exercise is an extension of the idea that contracts should be specified in terms of existing types, not in terms of type capabilities.
package main
import (
"fmt"
)
type Stream func() (int,bool)
func (s Stream) Filter(pred func(int) bool) Stream {