comp.lang.ada
 help / color / mirror / Atom feed
* Mixing operators and dot notation
@ 2016-06-02 21:38 Alejandro R. Mosteo
  2016-06-02 21:42 ` Alejandro R. Mosteo
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Alejandro R. Mosteo @ 2016-06-02 21:38 UTC (permalink / 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;

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-06-08 11:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-02 21:38 Mixing operators and dot notation Alejandro R. Mosteo
2016-06-02 21:42 ` 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

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