Patterns as objects in grace

Michael Homer, J. Noble, Kim B. Bruce, A. Black, David J. Pearce
{"title":"Patterns as objects in grace","authors":"Michael Homer, J. Noble, Kim B. Bruce, A. Black, David J. Pearce","doi":"10.1145/2384577.2384581","DOIUrl":null,"url":null,"abstract":"Object orientation and pattern matching are often seen as conflicting approaches to program design. Object-oriented programs place type-dependent behavior inside objects and invoke it via dynamic dispatch, while pattern-matching programs place type-dependent behavior outside data structures and invoke it via multiway conditionals (case statements). Grace is a new, dynamic, object-oriented language designed to support teaching: to this end, Grace needs to support both styles. We explain how this conflict can be resolved gracefully: by modelling patterns and cases as partial functions, reifying those functions as objects, and then building up complex patterns from simpler ones using pattern combinators. We describe the implementation of this design as an object-oriented framework, and a case study of its effectiveness.","PeriodicalId":225699,"journal":{"name":"Proceedings of the 8th symposium on Dynamic languages","volume":"279 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2012-10-22","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"25","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 8th symposium on Dynamic languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2384577.2384581","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 25

Abstract

Object orientation and pattern matching are often seen as conflicting approaches to program design. Object-oriented programs place type-dependent behavior inside objects and invoke it via dynamic dispatch, while pattern-matching programs place type-dependent behavior outside data structures and invoke it via multiway conditionals (case statements). Grace is a new, dynamic, object-oriented language designed to support teaching: to this end, Grace needs to support both styles. We explain how this conflict can be resolved gracefully: by modelling patterns and cases as partial functions, reifying those functions as objects, and then building up complex patterns from simpler ones using pattern combinators. We describe the implementation of this design as an object-oriented framework, and a case study of its effectiveness.
图案是优雅的对象
面向对象和模式匹配通常被视为程序设计中相互冲突的方法。面向对象程序将依赖类型的行为放在对象内部,并通过动态调度调用它,而模式匹配程序将依赖类型的行为放在数据结构外部,并通过多路条件(case语句)调用它。Grace是一种新的、动态的、面向对象的语言,旨在支持教学:为此,Grace需要支持两种风格。我们将解释如何优雅地解决这种冲突:通过将模式和用例建模为部分函数,将这些函数具体化为对象,然后使用模式组合子从简单模式构建复杂模式。我们将这种设计的实现描述为一个面向对象的框架,并对其有效性进行了案例研究。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信