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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,4ce5890331a5b529 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Discriminants of tagged types Date: Wed, 27 Oct 2010 20:35:44 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <14314714-e92c-4036-9cbb-da8e72489261@h7g2000yqn.googlegroups.com> <989c6412-8dbf-403c-9ce0-766e0e953fb6@u17g2000yqi.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1288226130 32116 192.74.137.71 (28 Oct 2010 00:35:30 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 28 Oct 2010 00:35:30 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:/BXSzoGRs6RWXl4VKB1z1FhDZJQ= Xref: g2news1.google.com comp.lang.ada:14874 Date: 2010-10-27T20:35:44-04:00 List-Id: Maciej Sobczak writes: >> The latest GNAT says: >> >> � � �1. with Ada.Finalization; use Ada.Finalization; >> � � �2. package Eg is >> � � �3. � �type T (X: Boolean := False) is private; >> � � �4. private >> � � �5. � �type T (X: Boolean := False) is new Controlled with null >> � � �record; >> � � � � � � � � � � � � � � � � �| >> � � � � >>> discriminants of tagged type cannot have defaults >> >> � � �6. end Eg; > > My compiler eats this stuff without even blinking. It complains only > when I add the "tagged" keyword in line 3, between "is" and "private". OK, well then it's a compiler bug that has since been fixed. Now that I think about it, I think I remember a recent bug in this area. I'll bet if you tried hard enough, you'd find some cases where the compiler generated code that did strange things (before the bug was fixed, I mean). > Protected objects, tasks and records already supported it. Records never supported this notation for calls, which I thought was what we're talking about. I wasn't a big fan of it for tasks or protected objects, either. But at least for these things, a "distinguished receiver" does make sense, because there's only one object getting locked. And because inside the operation, you can only see inside that one object. That is, in X.Y(Z), X is special in the protected object case, but X and Z are just normal parameters in the normal tagged case. >... It is not a > new idea, so it wasn't that big deal for compiler writers, I guess. Well, it was. Maybe it wouldn't have been if this new syntax had been invented in the first place, but adding this sort of thing into an existing compiler can be quite a pain. > I treat it as a unification of syntax across these similar features - > quite a valid goal in language design. > > This is especially reasonable if you take into account that in Ada > 2005 protected types can derive from interfaces. It would be very > inconsistent not to allow the same calling syntax across the whole > hierarchy, including the class-wide type. Good point. But I'd prefer to unify the syntax in the other direction. - Bob