Programmable semantic fragments: the design and implementation of typy

Cyrus Omar, Jonathan Aldrich
{"title":"Programmable semantic fragments: the design and implementation of typy","authors":"Cyrus Omar, Jonathan Aldrich","doi":"10.1145/2993236.2993245","DOIUrl":null,"url":null,"abstract":"This paper introduces typy, a statically typed programming language embedded by reflection into Python. typy features a fragmentary semantics, i.e. it delegates semantic control over each term, drawn from Python's fixed concrete and abstract syntax, to some contextually relevant user-defined semantic fragment. The delegated fragment programmatically 1) typechecks the term (following a bidirectional protocol); and 2) assigns dynamic meaning to the term by computing a translation to Python. We argue that this design is expressive with examples of fragments that express the static and dynamic semantics of 1) functional records; 2) labeled sums (with nested pattern matching a la ML); 3) a variation on JavaScript's prototypal object system; and 4) typed foreign interfaces to Python and OpenCL. These semantic structures are, or would need to be, defined primitively in conventionally structured languages. We further argue that this design is compositionally well-behaved. It avoids the expression problem and the problems of grammar composition because the syntax is fixed. Moreover, programs are semantically stable under fragment composition (i.e. defining a new fragment will not change the meaning of existing program components.)","PeriodicalId":405898,"journal":{"name":"Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences","volume":"53 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2016-10-20","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"5","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2993236.2993245","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 5

Abstract

This paper introduces typy, a statically typed programming language embedded by reflection into Python. typy features a fragmentary semantics, i.e. it delegates semantic control over each term, drawn from Python's fixed concrete and abstract syntax, to some contextually relevant user-defined semantic fragment. The delegated fragment programmatically 1) typechecks the term (following a bidirectional protocol); and 2) assigns dynamic meaning to the term by computing a translation to Python. We argue that this design is expressive with examples of fragments that express the static and dynamic semantics of 1) functional records; 2) labeled sums (with nested pattern matching a la ML); 3) a variation on JavaScript's prototypal object system; and 4) typed foreign interfaces to Python and OpenCL. These semantic structures are, or would need to be, defined primitively in conventionally structured languages. We further argue that this design is compositionally well-behaved. It avoids the expression problem and the problems of grammar composition because the syntax is fixed. Moreover, programs are semantically stable under fragment composition (i.e. defining a new fragment will not change the meaning of existing program components.)
可编程语义片段:类型的设计与实现
本文介绍了通过反射嵌入Python的静态类型编程语言type。type的特点是片断语义,即它将从Python固定的具体和抽象语法中提取的每个术语的语义控制委托给一些与上下文相关的用户定义语义片段。委托片段以编程方式1)类型检查术语(遵循双向协议);2)通过计算Python的翻译为术语赋予动态含义。我们认为这种设计是表达的片段的例子,表达静态和动态语义1)功能记录;2)标记的和(与la ML匹配的嵌套模式);3) JavaScript原型对象系统的变体;4) Python和OpenCL的类型化外部接口。这些语义结构是(或需要)用传统结构语言进行基本定义的。我们进一步认为,这种设计在结构上表现良好。它避免了表达式问题和语法组成问题,因为语法是固定的。此外,在片段组合下,程序在语义上是稳定的(即定义一个新的片段不会改变现有程序组件的含义)。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约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学术文献互助群
群 号:481959085
Book学术官方微信