comp.lang.ada
 help / color / mirror / Atom feed
From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Mixing operators and dot notation
Date: Thu, 2 Jun 2016 23:38:47 +0200
Date: 2016-06-02T23:38:47+02:00	[thread overview]
Message-ID: <niq90k$u7l$1@dont-email.me> (raw)

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;

             reply	other threads:[~2016-06-02 21:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 21:38 Alejandro R. Mosteo [this message]
2016-06-02 21:42 ` Mixing operators and dot notation Alejandro R. Mosteo
2016-06-02 22:28 ` Robert A Duff
2016-06-02 23:26   ` Randy Brukardt
2016-06-03 11:09     ` Alejandro R. Mosteo
2016-06-03 12:19       ` Dmitry A. Kazakov
2016-06-03 14:45       ` G.B.
2016-06-03 17:31       ` Shark8
2016-06-03 20:41         ` Alejandro R. Mosteo
2016-06-06  8:14           ` briot.emmanuel
2016-06-06 13:51             ` Alejandro R. Mosteo
2016-06-07 11:24             ` Traits and iterators (was: Mixing operators and dot notation) Alejandro R. Mosteo
2016-06-08  7:31               ` briot.emmanuel
2016-06-08 11:18                 ` Traits and iterators Alejandro R. Mosteo
2016-06-06  8:10       ` Mixing operators and dot notation briot.emmanuel
2016-06-06 13:58         ` Alejandro R. Mosteo
2016-06-02 23:05 ` Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox