ABSTRACT

This paper explores the feasibility of implementing pattern matching for the Go programming language. The design of pattern matching is taken from Scala, and reimplemented using Go's constructs and new language extensions, namely casestruct and trait.

The evaluations show that pattern matching allows expressing decomposition for struct in concise forms. The concepts of casestruct and trait are suggested to add to the Go language in order to make it properly supports pattern matching. However, the performance of the current implementation is still slower than hand-written struct decompositions. The evaluations also suggest that performance penalty of the type embedding feature proposed by Go for inheritance-like relationship is found in the GCCGO implementation, but not in another implementation, namely 8g.