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.
- G. Bracha and W. Cook. Mixin-based inheritance. In Proceedings of the European conference on object-oriented programming on Object-oriented programming systems, languages, and applications, OOPSLA/ECOOP '90, pages 303--311, New York, NY, USA, 1990. ACM. Google ScholarDigital Library
- H. Chafi, Z. DeVito, A. Moors, T. Rompf, A. K. Sujeeth, P. Hanrahan, M. Odersky, and K. Olukotun. Language virtualization for heterogeneous parallel computing. In Proceedings of the ACM international conference on Object oriented programming systems languages and applications, OOPSLA '10, pages 835--847, New York, NY, USA, 2010. ACM. Google ScholarDigital Library
- B. Chin and T. Millstein. An extensible state machine pattern for interactive applications. In Proceedings of the 22nd European conference on Object-Oriented Programming, ECOOP '08, pages 566--591, Berlin, Heidelberg, 2008. Springer-Verlag. Google ScholarDigital Library
- S. Don, G. Neverov, and J. Margetson. Extensible pattern matching via a lightweight language extension. In Proceedings of the 12th ACM SIGPLAN international conference on Functional programming, ICFP '07, pages 29--40, New York, NY, USA, 2007. ACM. Google ScholarDigital Library
- S. Ducasse, O. Nierstrasz, N. Schärli, R. Wuyts, and A. P. Black. Traits: A mechanism for fine-grained reuse. ACM Trans. Program. Lang. Syst., 28:331--388, March 2006. Google ScholarDigital Library
- B. Emir, M. Odersky, and J. Williams. Matching objects with patterns. In E. Ernst, editor, ECOOP 2007 -- Object-Oriented Programming, volume 4609 of Lecture Notes in Computer Science, pages 273--298. Springer Berlin/Heidelberg, 2007. 10.1007/978-3-540-73589-2_14. Google ScholarDigital Library
- M. Erwig. Active patterns. In Selected Papers from the 8th International Workshop on Implementation of Functional Languages, pages 21--40, London, UK, 1997. Springer-Verlag. Google ScholarDigital Library
- R. Forax and G. Roussel. Recursive types and Pattern-Matching in Java. In Proceedings of the First International Symposium on Generative and Component-Based Software Engineering, GCSE '99, pages 147--164, London, UK, 2000. Springer-Verlag. Google ScholarDigital Library
- J. Garrigue. Typing deep pattern-matching in presence of polymorphic variants. In JSSST Workshop on Programming and Programming Languages, Gamagori, Japan, 2004.Google Scholar
- Golang.org. Effective Go - The Go Programming Language. http://golang.org/doc/effective_go.html; Accessed May 2011.Google Scholar
- Golang.org. The Go Programming Language. http://golang.org; Accessed May 2011.Google Scholar
- P. Gustafsson and K. Sagonas. Native code compilation of Erlang's bit syntax. In Proceedings of the 2002 ACM SIGPLAN workshop on Erlang, ERLANG '02, pages 6--15, New York, NY, USA, 2002. ACM. Google ScholarDigital Library
- N. A. Hamid. Pattern matching on objects in Java. Journal of Computing Sciences in Colleges, 25:51--57, Oct. 2009. Google ScholarDigital Library
- L. Jategaonkar and J. Mitchell. ML with extended pattern matching and subtypes. In Proceedings of the 1988 ACM conference on LISP and functional programming, LFP '88, pages 19--211, New York, NY, USA, 1988. ACM. Google ScholarDigital Library
- J. Liu and A. C. Myers. JMatch: Iterable abstract pattern matching for Java. In Proceedings of the 5th International Symposium on Practical Aspects of Declarative Languages, PADL '03, pages 110--127, London, UK, UK, 2003. Springer-Verlag. Google ScholarDigital Library
- P. Moreau, C. Ringeissen, and M. Vittek. A pattern matching compiler for multiple target languages. In Proceedings of the 12th international conference on Compiler construction, CC'03, pages 61--76, Berlin, Heidelberg, 2003. Springer-Verlag. Google ScholarDigital Library
- M. Odersky and P. Wadler. Pizza into Java: translating theory into practice. In Proceedings of the 24th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, POPL '97, pages 146--159, New York, NY, USA, 1997. ACM. Google ScholarDigital Library
- M. Odersky and M. Zenger. Scalable component abstractions. In Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, OOPSLA '05, pages 41--57, New York, NY, USA, 2005. ACM. Google ScholarDigital Library
- T. Rompf and M. Odersky. Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs. In Proceedings of the ninth international conference on Generative programming and component engineering, GPCE '10, pages 127--136, New York, NY, USA, 2010. ACM. Google ScholarDigital Library
- W. Schuster. Rob Pike on Google Go: Concurrency, Type System, Memory Management and GC. http://www.infoq.com/interviews/pike-google-go; Accessed May 2011.Google Scholar
- M. Sulzmann, E. S. L. Lam, and P. V. Weert. Actors with multi-headed message receive patterns. In Proceedings of the 10th international conference on Coordination models and languages, COORDINATION'08, pages 315--330, Berlin, Heidelberg, 2008. Springer-Verlag. Google ScholarDigital Library
- P. Wadler. Views: a way for pattern matching to cohabit with data abstraction. In Proceedings of the 14th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, POPL '87, pages 307--313, New York, NY, USA, 1987. ACM. Google ScholarDigital Library
Index Terms
- Pattern matching for object-like structures in the Go programming language
Recommendations
Formal validation of pattern matching code
PPDP '05: Proceedings of the 7th ACM SIGPLAN international conference on Principles and practice of declarative programmingWhen addressing the formal validation of generated software, two main alternatives consist either to prove the correctness of compilers or to directly validate the generated code. Here, we focus on directly proving the correctness of compiled code ...
Optimising First-Class Pattern Matching
SLE 2022: Proceedings of the 15th ACM SIGPLAN International Conference on Software Language EngineeringPattern matching is a high-level notation for programs to analyse the shape of data, and can be optimised to efficient low-level instructions. The Stratego language uses first-class pattern matching, a powerful form of pattern matching that ...
Compiling contextual objects: bringing higher-order abstract syntax to programmers
PLPV '13: Proceedings of the 7th workshop on Programming languages meets program verificationBinders in data-structures representing code or proofs can be represented in a variety of ways, from low-level first-order representations such as de Bruijn indices to higher-order abstract syntax (HOAS), with nominal logic somewhere in-between.
HOAS is ...
Comments