comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Basic issue with dotted notation and tagged types
Date: Mon, 22 Oct 2012 00:55:08 +0200
Date: 2012-10-22T00:55:08+02:00	[thread overview]
Message-ID: <op.wmjwl6mdule2fv@cardamome> (raw)

I can't remember if this was already discussed here, somewhere in a  
rationale or an RM comment, here is something I really don't like, with a  
field (or member) of a tagged type and a function, both of the same name;  
a very basic case:


     with Ada.Text_IO;

     procedure Test2 is

        package IO renames Ada.Text_IO;

        -- type T is tagged;
        -- function F (E : T'Class) return Character;

        type T
           is tagged record
              F : Character := 'A';
           end record;

        function F
          (E : T'Class)
           return Character
           is ('B');

        E : T;
        C : Character := E.F; -- The function or the field?
     begin
        IO.Put (C);
     end;


Will this display `A` or `B`? Actually, the program compiled with GNAT  
4.6, displays `A`. It displays the same even when the two commented lines  
are commented‑out and thus the function `F` is declared before the field  
`F`. I can't remember if the RM have special wordings about it, but I feel  
this does not honour the principle of least surprise. May be this should  
be disallowed, to access any one of the two, when both are together  
visible from a scope?


-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University



             reply	other threads:[~2012-10-27 23:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-21 22:55 Yannick Duchêne (Hibou57) [this message]
2012-10-22  7:46 ` Basic issue with dotted notation and tagged types J-P. Rosen
2012-10-22  8:02   ` Dmitry A. Kazakov
2012-10-22 13:46     ` Yannick Duchêne (Hibou57)
2012-10-22 10:52   ` Marius Amado-Alves
2012-10-22 11:18     ` Georg Bauhaus
2012-10-22 11:37       ` Marius Amado-Alves
2012-10-22 14:11       ` Yannick Duchêne (Hibou57)
2012-10-22 11:45     ` Niklas Holsti
2012-10-22 14:17       ` Maciej Sobczak
2012-10-22 13:50     ` Yannick Duchêne (Hibou57)
2012-10-22 10:41 ` AdaMagica
replies disabled

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