comp.lang.ada
 help / color / mirror / Atom feed
From: "John G. Volan" <johnvolan@sprintmail.com>
Subject: Re: Warning: Religious naming convention discussion :-) [was: assign help!!]
Date: 1997/05/11
Date: 1997-05-11T00:00:00+00:00	[thread overview]
Message-ID: <3376B522.3EA1@sprintmail.com> (raw)
In-Reply-To: dewar.863365392@merv


Robert Dewar wrote:
> 
> John G. Volan wrote:
> 
> > But once again, I'd want the rule to be simple and minimalistic: Just
> > always mark access types (and access objects) with "_Pointer".
> 
> Bad suggestion. Access types are NOT pointers. They may be implemented using
> pointers some of the time (but not all the time -- we often find people
> using GNAT being surprised to find that access types are not always
> represented using simple pointers in some cases, but of course there is
> nothing in the language that suggests or requires that access types be
> implemented using pointers).

I think you're reading too much into my usage of the word "pointer". I
did not mean at all to imply any implementation details by using this
word, in fact I had in mind exactly the high-level abstraction of an
access type. I'm a bit surprised that "pointers" would somehow be a
low-level implementation concept. Ever since my Pascal days, I've always
viewed them as quite a high level abstraction.  Today, with my
experience with Ada, I'd tend to use "Address" for the low-level
implementation, and indeed, access types are not necessarily simple
addresses.  Perhaps your interpretation of "pointer" comes from C, where
pointers seem to be treated synonymously with addresses. (Although I'm
not so sure about that, aren't C pointers sometimes implemented as an
address plus an element index?)

In fact, the only reason I would suggest this usage would be when you
are providing an abstraction that includes both a designated type and a
visible access type -- _both_ as part of the visible interface.  Both
types would relate to the same concept, but they would still need to be
differentiated by each other. So one type must be marked somehow. 
"_Pointer" seems a convenient marker, but if that hits any raw nerves,
how about "_Access"?

   package Targets is

     type Target_Type is tagged limited private;
     type Target_Access_Type is access all Target_Type'Class;
     ...

By the way, this would be a case where my naming convention might relax
a bit: Not every variable of Target_Access_Type would necessarily have
to be called [Optional_Prefix_]Target_Access.  The "_Access" could be
dropped if you were in a context where you were only working directly
with an access variable, and didn't have to have a separate name for the
designated object, e.g.:

    procedure Do_Something_Classwide (Target : in Target_Access_Type);

This is especially true if the access type were anonymous:

    procedure Do_Something_Primitive (Target : access Target_Type);

The only time "_Access" would have to be used in an object name would be
in (relatively rare) cases where you needed to name both the designated
object and the access object in the same scope.

The only difficulty with using "Access" as a marker instead of "Pointer"
is that "Access", being a reserved word, cannot stand alone as a
variable name. When would you want to do that?  Consider a generic:

    generic
      type Object_Type (<>) is limited private;
      type Pointer_Type is access all Object_Type;
    package Garbage_Collected_Refs is
      -- by convention, let "Ref" mean "Reference"

      type Ref_Type is private;

      function "+" (Pointer : in Pointer_Type) return Ref_Type;
      function "+" (Ref : in Ref_Type) return Pointer_Type;

    private
      type Ref_Type is new Controlled with ...
    end Garbage_Collected_Refs;

The first "+" overloading takes an access value and generates a
garbage-collected reference value for it, the second retrieves the
access value from a reference.  At this level of abstraction, we don't
have any particular designated type and access type, so there is no
compelling reason to mark the access parameter as anything other than
"Pointer".  If the convention were to use "Access", then we have
trouble:

   generic
     type Object_Type (<>) is limited private;
     type Object_Access_Type is access all Object_Type;
   package Garbage_Collected_Refs
      -- by convention, let "Ref" mean "Reference"

      type Ref_Type is private;

      function "+" (Object_Access : in Object_Access_Type) return
Ref_Type;
      function "+" (Ref : in Ref_Type) return Object_Access_Type;

    private
      type Ref_Type is new Controlled with ...
    end Garbage_Collected_Refs;

It might be misleading in this case to take the suggestion I made above
and drop "_Access" from the parameter and just call it "Object".  These
operations are more concerned with the access value rather than the
designated object.

> Suffixing access types with _Pointer emphasizes the confusion, and seems
> inappropriate to me. It is analogous to saying that all integer types
> should be suffixed with
> 
>   _Twos_Complement_Bit_String
> 
> or somesuch.

Reductio ad absurdum at its finest. :-)

> Names should be chosen to emphasize the meaning at an
> appropriate level of abstraction, not the low-level implementation
> dependent representation.

Why, I quite agree, and have already said so several times in this
discussion. We merely misunderstand each other as to which words refer
to abstractions and which to implementation details.

------------------------------------------------------------------------
Internet.Usenet.Put_Signature 
  (Name => "John G. Volan",  Home_Email => "johnvolan@sprintmail.com",
   Slogan => "Ada95: The World's *FIRST* International-Standard OOPL",
   Disclaimer => "These opinions were never defined, so using them " & 
     "would be erroneous...or is that just nondeterministic now? :-) ");
------------------------------------------------------------------------




  parent reply	other threads:[~1997-05-11  0:00 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-05  0:00 assign help!! Ivan Gou
1997-05-06  0:00 ` Michael F Brenner
1997-05-07  0:00   ` Charles H. Sampson
1997-05-08  0:00     ` Warning: Religious naming convention discussion :-) [was: assign help!!] John G. Volan
1997-05-09  0:00       ` Kevin Cline
1997-05-09  0:00         ` John G. Volan
1997-05-09  0:00       ` Jay Martin
1997-05-09  0:00         ` John G. Volan
1997-05-09  0:00         ` Jeff Carter
1997-05-09  0:00           ` John G. Volan
1997-05-09  0:00           ` John G. Volan
1997-05-10  0:00             ` Kaz Kylheku
1997-05-10  0:00               ` John G. Volan
1997-05-10  0:00             ` Robert Dewar
1997-05-10  0:00               ` John G. Volan
1997-05-11  0:00                 ` Robert Dewar
1997-05-12  0:00                   ` Robert I. Eachus
1997-05-13  0:00                     ` Robert Dewar
1997-05-16  0:00                       ` Robert I. Eachus
1997-05-17  0:00                         ` Robert Dewar
1997-05-13  0:00                     ` John G. Volan
1997-05-12  0:00                   ` John G. Volan
1997-05-11  0:00               ` Kevin Cline
1997-05-11  0:00                 ` Robert Dewar
1997-05-12  0:00                   ` John G. Volan
1997-05-12  0:00                     ` Robert Dewar
1997-05-16  0:00                 ` Wayne Magor
1997-05-16  0:00                   ` Robert Dewar
1997-05-18  0:00                     ` Nick Roberts
1997-05-20  0:00                     ` naming convention discussion Peter Hermann
1997-05-16  0:00                   ` Warning: Religious naming convention discussion :-) [was: assign help!!] John G. Volan
1997-05-14  0:00               ` Ben Brosgol
1997-05-14  0:00                 ` naming convention: trailing underscore Peter Hermann
1997-05-14  0:00                   ` John G. Volan
1997-05-15  0:00                   ` Michael F Brenner
     [not found]                 ` <dewar.863717431@merv>
1997-05-16  0:00                   ` Warning: Religious naming convention discussion :-) [was: assign help!!] Robert A Duff
1997-05-18  0:00                     ` Underscores in identifiers (was: Warning: Religious naming convention discussion :-) Ben Brosgol
1997-05-16  0:00                   ` naming convention discussion Peter Hermann
1997-05-16  0:00                     ` Robert Dewar
1997-05-20  0:00                       ` Peter Hermann
1997-05-17  0:00                   ` Warning: Religious naming convention discussion :-) [was: assign help!!] Arthur Schwarz
1997-05-17  0:00                     ` Robert Dewar
1997-05-17  0:00                       ` John G. Volan
1997-05-18  0:00                         ` Andrew Dunstan
1997-05-18  0:00                           ` Nick Roberts
1997-05-19  0:00                             ` John G. Volan
1997-05-19  0:00                             ` John G. Volan
1997-05-10  0:00             ` Aaron Metzger
1997-05-11  0:00               ` Robert Dewar
1997-05-11  0:00                 ` Robert A Duff
1997-05-12  0:00                   ` Robert Dewar
1997-05-12  0:00                     ` Robert A Duff
1997-05-12  0:00                       ` Robert Dewar
1997-05-13  0:00                         ` Robert A Duff
1997-05-13  0:00                           ` Kaz Kylheku
1997-05-14  0:00                             ` Robert A Duff
1997-05-14  0:00                             ` Kevin Cline
1997-05-14  0:00                               ` Robert Dewar
1997-05-13  0:00                           ` Robert Dewar
1997-05-14  0:00                             ` Ole-Hjalmar Kristensen FOU.TD/DELAB
1997-05-13  0:00                         ` David L Brown
1997-05-13  0:00                           ` W. Wesley Groleau (Wes)
1997-05-14  0:00                           ` Robert Dewar
1997-05-11  0:00                 ` John G. Volan [this message]
1997-05-12  0:00                 ` Kaz Kylheku
1997-05-11  0:00               ` Simon Wright
1997-05-12  0:00               ` John G. Volan
1997-05-12  0:00             ` W. Wesley Groleau (Wes)
1997-05-12  0:00               ` John G. Volan
1997-05-13  0:00                 ` W. Wesley Groleau (Wes)
1997-05-13  0:00                   ` John G. Volan
1997-05-14  0:00                     ` naming convention discussion Peter Hermann
1997-05-14  0:00                       ` John G. Volan
1997-05-14  0:00                         ` Peter Hermann
1997-05-14  0:00                           ` John G. Volan
1997-05-15  0:00                             ` Peter Hermann
1997-05-15  0:00                           ` W. Wesley Groleau (Wes)
1997-05-14  0:00                     ` Warning: Religious naming convention discussion :-) [was: assign help!!] Do-While Jones
1997-05-14  0:00                       ` Stephen Leake
1997-05-14  0:00                       ` John G. Volan
1997-05-14  0:00                         ` John G. Volan
1997-05-15  0:00                         ` Tangent to Religious naming convention discussion W. Wesley Groleau (Wes)
1997-05-15  0:00                           ` John G. Volan
1997-05-12  0:00             ` Warning: Religious naming convention discussion :-) [was: assign help!!] Jeff Carter
1997-05-12  0:00               ` John G. Volan
1997-05-10  0:00           ` Robert Dewar
1997-05-10  0:00             ` John G. Volan
1997-05-11  0:00               ` Robert Dewar
1997-05-12  0:00                 ` John G. Volan
1997-05-12  0:00               ` W. Wesley Groleau (Wes)
1997-05-12  0:00             ` W. Wesley Groleau (Wes)
1997-05-12  0:00               ` John G. Volan
1997-05-11  0:00           ` Doug Smith
1997-05-12  0:00           ` Tom Moran
1997-05-16  0:00           ` Wayne Magor
1997-05-16  0:00             ` John G. Volan
1997-05-17  0:00             ` Kevin Cline
1997-05-19  0:00               ` Doug Smith
1997-05-12  0:00       ` W. Wesley Groleau (Wes)
1997-05-12  0:00         ` John G. Volan
1997-05-12  0:00         ` John G. Volan
1997-05-10  0:00     ` assign help!! Simon Wright
1997-05-14  0:00       ` Nick Roberts
replies disabled

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