{"title":"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":"{\"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}","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}
An efficient method for handling operator overloading in Ada
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.