skip to main content
10.1145/2069172.2069180acmotherconferencesArticle/Chapter ViewAbstractPublication PagesecoopConference Proceedingsconference-collections
research-article

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

Authors Info & Claims
Published:26 July 2011Publication History

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. J. Garrigue. Typing deep pattern-matching in presence of polymorphic variants. In JSSST Workshop on Programming and Programming Languages, Gamagori, Japan, 2004.Google ScholarGoogle Scholar
  10. Golang.org. Effective Go - The Go Programming Language. http://golang.org/doc/effective_go.html; Accessed May 2011.Google ScholarGoogle Scholar
  11. Golang.org. The Go Programming Language. http://golang.org; Accessed May 2011.Google ScholarGoogle Scholar
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. N. A. Hamid. Pattern matching on objects in Java. Journal of Computing Sciences in Colleges, 25:51--57, Oct. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle Scholar
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

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

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Other conferences
      ICOOOLPS '11: Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems
      July 2011
      64 pages
      ISBN:9781450308946
      DOI:10.1145/2069172

      Copyright © 2011 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 26 July 2011

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate11of14submissions,79%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader