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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.159.39.225 with SMTP id b88mr2186805uab.27.1478530849224; Mon, 07 Nov 2016 07:00:49 -0800 (PST) X-Received: by 10.157.14.231 with SMTP id 94mr226712otj.9.1478530849179; Mon, 07 Nov 2016 07:00:49 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!2.us.feeder.erje.net!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!n6no1520912qtd.0!news-out.google.com!i74ni2807itb.0!nntp.google.com!q124no989094itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 7 Nov 2016 07:00:48 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.138.39.62; posting-account=wdPkaAoAAADVaTmA4kb8x-tgqIlcwEIS NNTP-Posting-Host: 194.138.39.62 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Dynamic_Predicate and dispatching call From: Duckysmokton Injection-Date: Mon, 07 Nov 2016 15:00:49 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:32259 Date: 2016-11-07T07:00:48-08:00 List-Id: Hello, I have a confusing issue with an Ada 2012 / GNAT 2016 program. Given a tagged type that has : * an abstract method that makes an unspecified calculation * a non-abstract method that performs a dispatching call to this calculation * a Dynamic_Predicate package Test_Dispatch is type t_Element_Array is array (Natural range <>) of Integer; type t_Base_Object is abstract tagged private; function get_One_Value (Self : in t_Base_Object; Element : in Natural) return Integer is abstract; function get_All_Values (Self : in t_Base_Object) return t_Element_Array with Extensions_Visible; -- needed for dispatching call private type t_Base_Object is abstract tagged record Element_Count : Positive; end record with Dynamic_Predicate => (t_Base_Object.Element_Count mod 2 = 0); end Test_Dispatch; package body Test_Dispatch is function get_All_Values (Self : in t_Base_Object) return t_Element_Array is begin return Answer : t_Element_Array (0..Self.Element_Count-1) do for Element in Answer'Range loop Answer (Element) := t_Base_Object'Class(Self).get_One_Value (Element); end loop; end return; end get_All_Values; end Test_Dispatch; Compilation fails on "t_Base_Object'Class(Self)." with : class-wide argument not allowed here If I remove the Dynamic_Predicate, it's OK. ARM does not mention restriction on dispatching calls and dynamic predicates, so, what is the problem ? Thanks for any advice. PS: - It also occurs if get_One_Value is not abstract (returns a defaultvalue) - get_All_Values parameter Self shall not be class-wide because it is a default method and derived objects might implement more efficient or appropriate algorithms (Troll bait : this would not happen with C++ !)