From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,81bb2ce65a3240c3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.195.165 with SMTP id if5mr91880pbc.1.1336722000804; Fri, 11 May 2012 00:40:00 -0700 (PDT) Path: pr3ni12858pbb.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: What would you like in Ada202X? Date: Fri, 11 May 2012 09:39:38 +0200 Organization: cbb software GmbH Message-ID: <1owsnk9aicgd2.12jwtputdghpa$.dlg@40tude.net> References: <3637793.35.1335340026327.JavaMail.geo-discussion-forums@ynfi5> <20780405.1069.1336372385458.JavaMail.geo-discussion-forums@pbkc8> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-05-11T09:39:38+02:00 List-Id: On Fri, 11 May 2012 00:22:30 +0300, Niklas Holsti wrote: > Ok, I see how that can work: you synthesize tags and perhaps other "type > descriptors" and pass them as hidden parameters to class-wide > operations. For a scalar type T and T'Class have different representations. That does the trick. No need in hidden parameters. You compose class-wide operation T'Class with type conversion T -> T'Class. This is the model #1. T is handled as if it were as a subtype of T'Class Tag can be considered a discriminant. T has Tag set to T and the representation with no tag stored. This is another language improvement I want to have: removable static discriminants with static operations on discriminants. Ideally you should be able to implement all arrays and OO-stuff manually. > One problem is that there would be two notions of Enum'Class: > > 1. If Enum'Class covers only enumeration types derived from Enum using > the current Ada derivation method, then the set of literals is the same > for all types in Enum'Class. This both simplifies and limits what a > class-wide operation can do. > > 2. If Enum'Class covers also "deepened" enumeration types, then > different types in Enum'Class can have completely different sets of > literals. However, a class-wide operation can rely on the fact that each > literal in Enum corresponds to a range of literals in any type in > Enum'Class. There needs to be some way (an attribute function?) to map > an Enum value to the range within the actual type of the class-wide > parameter. If literals are primitive operations. A. Literals are primitive function Foo return Enum. They are inherited and belong to the class. B. Literals are values, contravariant and not inherited. There is no much difference when enumeration have no classes. With classes one should make a choice. Since deepening effectively disallows operations in the model B, you will have problems with disallowed operations used on class-wide objects of the type which disallowed them. You could use a fallback to be last type which owned the operation or have Constraint_Exception in all class-wide contracts (Ada 95 approach). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de