comp.lang.ada
 help / color / mirror / Atom feed
From: "Hibou57 (Yannick Duchêne)" <yannick_duchene@yahoo.fr>
Subject: Re: Access types as parameters
Date: Fri, 17 Jul 2009 09:28:11 -0700 (PDT)
Date: 2009-07-17T09:28:11-07:00	[thread overview]
Message-ID: <f69aeaa5-5821-45ad-968b-489c7ccce67b@k19g2000yqn.googlegroups.com> (raw)
In-Reply-To: a245c71e-8f1b-47be-a8f4-2ebb2170f9e5@c29g2000yqd.googlegroups.com

Adam has already given a good answer, but I may say a bit the same in
shorter words :

access My_Type'Class in a function declaration, is a so called “
anonymous type ”, and as this type is only declared locally, it cannot
match any other types defined at wider level (beceause this would
simply not be type conformant).

access My_Type'Class does not have a so wide validity as
My_Access_Type may have.

This is conveniant and safe

More words....

As an hint : you may use My_Access_Type if the reference is to be
stored into a record (as an exemple) and may use access My_Type'Class
if you only need it locally. Looking at the function signature, you
may then quicly see what kind of things the function may allowed it-
self to do with the reference you gave it.

If you see the function wants an “ access My_Type'Class ”, you nearly
do not have to bother about anything, but if you see it wants a “
My_Access_Type ” you may need to be sure there is a good collaboration
between the caller and the callee. This is anyway, a good invitation
to read the function documentation (if comments are provided about its
usage).

But this does not means “ access My_Type'Class ” is better beceause it
is “ safer ” (quotes, beceause the other way is not always not safe),
as sometime, My_Access_Type is mandatory, depending on what the
function have to do with the reference.



  reply	other threads:[~2009-07-17 16:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-17  8:39 Access types as parameters Rick
2009-07-17 15:03 ` Adam Beneschan
2009-07-17 16:28   ` Hibou57 (Yannick Duchêne) [this message]
2009-07-17 23:25     ` rickduley
2009-07-18  1:03       ` Randy Brukardt
2009-07-19 22:57         ` rickduley
2009-07-20  0:10           ` John B. Matthews
2009-07-20  8:13           ` Dmitry A. Kazakov
2009-07-21  0:34           ` Randy Brukardt
2009-07-21 14:34           ` Adam Beneschan
2009-07-23  2:11             ` Stephen Leake
2009-08-11 23:41               ` Randy Brukardt
2009-08-12  2:22                 ` Stephen Leake
2009-08-13  1:06                   ` Randy Brukardt
2009-08-13  8:34                     ` Niklas Holsti
2009-08-13  9:15                       ` Dmitry A. Kazakov
2009-08-13 20:13                         ` Niklas Holsti
2009-08-13 21:07                           ` Dmitry A. Kazakov
2009-08-14  9:27                             ` Niklas Holsti
2009-08-14 10:36                               ` Dmitry A. Kazakov
2009-08-14 16:03                                 ` Niklas Holsti
2009-08-15  9:47                                   ` Dmitry A. Kazakov
2009-08-15 19:19                                     ` Niklas Holsti
2009-08-16  8:32                                       ` Dmitry A. Kazakov
2009-08-16  9:52                                         ` Niklas Holsti
2009-08-16 12:38                                           ` Dmitry A. Kazakov
2009-08-16 13:21                                             ` Niklas Holsti
2009-08-16 17:58                                               ` Dmitry A. Kazakov
2009-08-14  4:07                       ` Randy Brukardt
2009-08-14 10:22                         ` Niklas Holsti
2009-08-18 12:22                     ` Stephen Leake
replies disabled

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