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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Mixing operators and dot notation Date: Thu, 2 Jun 2016 23:42:35 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 2 Jun 2016 21:42:15 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="857d06a4b85f2c044993090b381d5d42"; logging-data="30965"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/i+WQAiLiTmIOm5jhRw9Aa" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-Reply-To: Cancel-Lock: sha1:wESgIb62lhWIkmagHJI9zG/gNyo= Xref: news.eternal-september.org comp.lang.ada:30558 Date: 2016-06-02T23:42:35+02:00 List-Id: Failed to say: tested with gnat gpl 2015 and 2016. On 02/06/16 23:38, Alejandro R. Mosteo wrote: > Hello all, > > I'm trying to abuse Ada syntax for nefarious purposes and have arrived > at something that looks inconsistent to me, but I fail to see if it is > expected behavior or a bug. This is a self-contained example which is > below. > > The gist is to have an operator that returns a class-wide type in order > to use dot notation on it. The problem is in the last statement. Should > it work just like the function version?: > > procedure Cla is > > generic > package Nested is > type Object is tagged null record; > procedure Method (O : Object) is null; > end Nested; > > package Nest is new Nested; > > function Op (X, Y : Integer) return Nest.Object'Class is > pragma Unreferenced (X, Y); > begin > return Nest.Object'(null record); > end Op; > > function "&" (X, Y : Integer) return Nest.Object'Class renames Op; > > N : Nest.Object'Class := Op (1, 2); > M : Nest.Object'Class := 1 & 2; -- Both work > > begin > N.Method; > M.Method; -- Of course both work > > Op (1, 2).Method; -- Fine > > -- (1 & 2).Method; -- Error: statement expected > end Cla;