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: 103376,9b7d3a51d0d8b6ee,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-2.dfn.de!news.uni-stuttgart.de!not-for-mail From: Stefan Bellon Newsgroups: comp.lang.ada Subject: Extending discriminant types Date: Sat, 15 Nov 2008 10:16:32 +0100 Organization: Comp.Center (RUS), U of Stuttgart, FRG Message-ID: <20081115101632.5f98c596@cube.tz.axivion.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: infosun2.rus.uni-stuttgart.de 1226740593 24483 129.69.226.23 (15 Nov 2008 09:16:33 GMT) X-Complaints-To: news@news.uni-stuttgart.de NNTP-Posting-Date: Sat, 15 Nov 2008 09:16:33 +0000 (UTC) X-Newsreader: Claws Mail 3.5.0 (GTK+ 2.12.11; i486-pc-linux-gnu) X-URL: http://www.axivion.com/ Xref: g2news1.google.com comp.lang.ada:2682 Date: 2008-11-15T10:16:32+01:00 List-Id: Hi, I stumbled across some behaviour when extending an unconstrained discriminant type while providing the constraint when extending. Assume the following code: type Kind is (A, B); type Base (K : Kind) is abstract tagged record case K is when A => null; when B => Dummy : Natural; end case; end record; type Base_Access is access all Base'Class; type Child is new Base (B) with null record; In this case I would have thought that type Child is now constrained to Kind B and no object of type Child with Kind A can be created. However, the following compiles (with GNAT) and does not throw an exception at runtime: Var : Base_Access := new Child'(K => A); Am I misunderstanding the Ada semantics? If so, is there a way to achieve what I'm trying, i.e. that I can determine the Kind while extending and not change it when creating objects? Greetings, Stefan