An efficient method for handling operator overloading in Ada

E. Schonberg, Gerald A. Fisher
{"title":"An efficient method for handling operator overloading in Ada","authors":"E. Schonberg, Gerald A. Fisher","doi":"10.1145/3304133.3304148","DOIUrl":null,"url":null,"abstract":"The coupling of type derivation with operator overloading occupies a substantial portion of the type-checking activities of an Ada compiler. It is thus important to handle overloaded operators as efficiently as possible. Let us recall that the introduction of any type derived from a numeric type, say: type T is range 1 .. 10; (1) creates, at the point of declaration of type T, a new instance of each of the predefined operators that apply to the root type of T, namely INTEGER. In other words, declarations of the form function \"+\"(x, y : T'BASE) return T'BASE; (2) are understood to appear immediately after the declaration (1). (Here T'BASE refers to the anonymous type, derived from integer, of which type T is a subtype). This means that an innocent declaration such as (1) introduces implicitly 16 new operator declarations (10 arithmetic operators and 6 comparison operators). The visibility of operator designators such as \"+\" is described in [RM] in terms of these implicit declarations. In what follows we refer to the operators thus introduced as derived operators, in contrast with user-defined operators, which are introduced by explicit declarations and are given user-defined bodies.","PeriodicalId":304626,"journal":{"name":"Proceedings of the AdaTEC Conference on Ada","volume":"158 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"1982-10-06","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"3","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the AdaTEC Conference on Ada","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3304133.3304148","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 3

Abstract

The coupling of type derivation with operator overloading occupies a substantial portion of the type-checking activities of an Ada compiler. It is thus important to handle overloaded operators as efficiently as possible. Let us recall that the introduction of any type derived from a numeric type, say: type T is range 1 .. 10; (1) creates, at the point of declaration of type T, a new instance of each of the predefined operators that apply to the root type of T, namely INTEGER. In other words, declarations of the form function "+"(x, y : T'BASE) return T'BASE; (2) are understood to appear immediately after the declaration (1). (Here T'BASE refers to the anonymous type, derived from integer, of which type T is a subtype). This means that an innocent declaration such as (1) introduces implicitly 16 new operator declarations (10 arithmetic operators and 6 comparison operators). The visibility of operator designators such as "+" is described in [RM] in terms of these implicit declarations. In what follows we refer to the operators thus introduced as derived operators, in contrast with user-defined operators, which are introduced by explicit declarations and are given user-defined bodies.
Ada中处理运算符重载的一种有效方法
类型派生与操作符重载的耦合占据了Ada编译器类型检查活动的很大一部分。因此,尽可能高效地处理重载操作符是非常重要的。让我们回忆一下,从数字类型派生的任何类型的引入,例如:类型T的范围为1 ..10;(1)在声明类型T时,为应用于T的根类型(即INTEGER)的每个预定义操作符创建一个新实例。换句话说,函数"+"(x, y: T'BASE)形式的声明返回T'BASE;(2)被理解为紧跟在声明(1)之后出现(这里T'BASE指的是匿名类型,从整数派生而来,类型T是其子类型)。这意味着(1)这样的简单声明隐式引入了16个新的操作符声明(10个算术操作符和6个比较操作符)。像“+”这样的操作符指示符的可见性在[RM]中根据这些隐式声明进行了描述。在接下来的内容中,我们将这样引入的操作符称为派生操作符,与用户定义操作符形成对比,用户定义操作符由显式声明引入,并给出用户定义的主体。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约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学术官方微信