Pattern matching for object-like structures in the Go programming language

  • Authors:
  • Chanwit Kaewkasi;Pitchaya Kaewkasi

  • Affiliations:
  • Suranaree University of Technology, Nakhon Ratchasima, Thailand;Suranaree University of Technology, Nakhon Ratchasima, Thailand

  • Venue:
  • Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

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.