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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e12ee9b0877029b2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-12 18:53:45 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Disagreement between GNAT and Cohen? Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Thu, 13 Jun 2002 01:52:59 GMT References: <3D05456D.7050001@golter.demon.co.uk> <3D05A559.9020502@golter.demon.co.uk> NNTP-Posting-Host: shell01.theworld.com Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:25841 Date: 2002-06-13T01:52:59+00:00 List-Id: Andrew Hoddinott writes: > I'm still puzzled though. Cohen's actual example (p. 696-7) is: > > generic > type Element_Type is (<>); > package Generic_Discrete_Sets is > type Set_Type is private; > function Union (Set_1, Set_2 : Set_Type ) return Set_Type; > -- ... more functions and types > private > type Set_Type is array (Element_Type) of Boolean; > end Generic_Discrete_Sets; > > package body Generic_Discrete_Sets is > function Union (Set_1, Set_2 : Set_Type) return Set_Type > renames "or"; > -- ... more function bodies > end Generic_Discrete_Sets; This code looks wrong to me. I don't understand the GNAT error message, though. > generating the errors: > generic_discrete_sets.adb:2:04: not subtype conformant with declaration > in package Standard > generic_discrete_sets.adb:2:04: return type does not match > > He specifically draws attention to the package body using "the versions > of the logical operators 'and', 'or', and 'not' that apply component by > component to one-dimensional arrays of Boolean values", and bases an > exercise (15.3) around the example too. > > Is he just making this up? Perhaps Norm Cohen compiled the code with an early version of GNAT that didn't check the rule. I believe the GNAT implementation generates a dummy body for a renaming-as-body, so it would work just fine. What Cohen is trying to do is perfectly reasonable -- the rule is not there for semantic reasons, but to ease a certain implementation technique. In hindsight, I think the rule is misguided. >... Or is there some way that the frozen-ness of > the intrinsic logical operators can vary between compilers so that this > example sometimes works? No, all compilers should agree on this. >... And the intrinsic not getting an explicit > mention in the error message in this slightly more complex case is > because ... ? Beats me. > Sorry. Since I know how to work around the problem, I should probably > just shut up and go on to the next exercise, but ... ;-) Nothing wrong with trying to understand the language. ;-) - Bob