comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Basic issue with dotted notation and tagged types
Date: Mon, 22 Oct 2012 14:45:28 +0300
Date: 2012-10-22T14:45:28+03:00	[thread overview]
Message-ID: <aekpuoFodmfU1@mid.individual.net> (raw)
In-Reply-To: <23619b66-91a4-4786-b210-8012e648e631@googlegroups.com>

On 12-10-22 13:52 , Marius Amado-Alves wrote:
>> RM2005 4.1.3 (9.2/2): "The designator of the subprogram shall not be the
>> same as that of a component of the tagged type visible at the point of
>> the selected_component."
> 
> Hmm... shouldn't the compiler complain then? (about the program above)

No, the quoted RM part just says that the prefixed call notation
(object.operation) is available /only/ when there is no (visible)
component that has the same name as the operation. If there is a
(visible) component with the same name, then the component effectively
hides the operation, in the object.name syntax.

So the program is legal. However, it may not work as the programmer
intended. An optional compiler warning could be helpful.

This really seems too much of a trap to accept silently. Just for
example, suppose there is a class hierarchy, and Ob is an object of some
derived type, and Foo some primitive operation of this derived type. The
meaning of Ob.Foo then depends on whether or not some level of the
hierarchy adds a component Foo to the type, and whether the component is
visible or not. Yuck! Most cases of confusion will probably be caught by
some type mismatch (or lack of actual parameters), but some will pass
undetected by the compiler.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  parent reply	other threads:[~2012-10-28  2:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-21 22:55 Basic issue with dotted notation and tagged types Yannick Duchêne (Hibou57)
2012-10-22  7:46 ` 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 [this message]
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