comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Naming of Tagged Types and Associated Packages
Date: 1998/07/28
Date: 1998-07-28T00:00:00+00:00	[thread overview]
Message-ID: <m3emv76ret.fsf@mheaney.ni.net> (raw)
In-Reply-To: 6pi71p$n90$1@platane.wanadoo.fr

"Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr> writes:

> The *type* definition by itself only defines the data. It is the fact that
> some operations are defined in the same *package specification* as the type
> that makes them bound to the type. Yes, a package is an encapsulation
> mechanism; it is the encapsulation that transforms a type + some operations
> in a "class".

When I think of "type," I don't just think of the statement 

   type T is ...;

I think of "type" as 

1) The name of the type, introduced by a type declaration of the form
"type T is ..."

2) The primitive operations of the type, which are the subprograms that
take the type named T as a parameter, and are declared in the same
package as the type declaration.

I do not equate "type" with the statement "type T is ...", and that
seems to be where you and I part ways.  A type is more than that, as it
comprises a name, some data, and some operations.  You call this thing a
"class," but I prefer to stick to Ada terminology.  

The Ada statement "type T is ..." tells me the name (and ultimately the
representation), but that is not equivalent to a "type"; it isn't enough
to be a type.
 
> >The use of the convention "P.Instance" to refer to the "real" type name
> >is very misguided, because it's as if you're trying to make a package
> >into a type, which it is not.
> In this case, the package is the "class".

I don't make a distinction between "type" and "class."  The Ada term is
for type is "type," and the term "class" means "family of types."

Again, let's go back to the RM:

Text_IO.File_Type 
  is not called File.Instance

Ada.Strings.Unbounded.Unbounded_String
  is not called Ada.Strings.Unbounded_String.Instance

Ada.Tags.Tag 
  is not called Ada.Tag.Instance

System.Storage_Elements.Storage_Element 
  is not called System.Storage_Element.Instance


Why don't Ada programmers like to do what's in the RM?



> >> Now the package may declare
> >> some utility types in addition to the "main" type; it makes sense to have
> >> some notation to distinguish this main type. "Instance" or "Object" look
> >> nice in a declaration like:
> >>     My_Account: Bank_Account.Instance;
> >
> >You may think it looks nice, but I read this and think "Je crois qu'elle
> >est laide."  Why not just
> >   My_Account: Bank_Account;
> 
> This is a very important issue in naming, which is much more general than
> even this discussion.
> Should a type name be descriptive of what the *type* is, or should it be
> descriptive of what the *variables* are ?
> In other terms, when you read:
>     A : T;
> do you read it as "A is of type T" or as "A is a T" ?

Both.  Because there is no difference.

> In the second case, my notation would directly read "My_Account is an
> instance of Bank_Account". 

When I see the declaration

   My_Account : Bank_Account;

I think "My_Account is an instance of Bank_Account."  How else would you
interpret it?


> Other people may read it differently.

I have to believe you that there are "other people" who read it
differently, but it seems pretty obvious to me that the declaration

   O : T;

means "Object O is an instance of type T."

If these people are that confused about the nature of a declaration,
then I'm not sure a naming convention is going to be enough to end their
confusion.

> Then, you miss the real issue. Actually, I wrote a book some times ago (in
> French, and I still don't have a publisher for the english translation,
> anybody's listening? ;-), and I stumbled into the problem of a consistent
> notation for generics. That was the main triggering reason for that
> notation. Since you didn't seem to keep you backlog of Ada Letters, let me
> summarize the issue.
> 
> Assume (your notation):
> package Bank_Accounts is
>     type Bank_Account is tagged...
>    -- operations ....
> end Bank_Account;
> 
> Assume that some bank accounts are "privileged" in some sense. You want a
> generic to allow this on any bank_account:
> generic
>     with old_account is new Bank_Account with private;
> package Privileged_Account is
>    type ??? is new old_Account with private;
>    --- other operations
> end Privileged_Account;

What's wrong with the convention

generic
   type Account_Type is new Bank_Account with private;
package Privileged_Mixin is

   type Privileged_Account is new Account_Type with private;
...
end Privileged_Mixin;


> The trouble is that when you instantiate the generic, you can choose the
> name of the new package, but not the names of what is declared inside, and
> especially the type. I you want the type name to carry the useful
> information, the type name should change with each instantiation! With my
> notation, the package name carries the useful information, and therefore the
> same convention can be used for packages obtained by generic instantiations
> and for regular packages.

I suppose you could just do another local type derivation, or declare a
local subtype.  This isn't a big issue for me.  I'm happy enough to be
able to determine the characteristics of the type once, at point of
instantiation, rather than being reminded every object declaration.

> >We obviously have philosophical differences about the nature of a type.
> >Oh, well.  I'll be in Paris in September: perhaps we can meet at a cafe
> >to discuss it more over "une pression"!
> I'd be glad to. Just drop me a note when you know when you are there.

Oui, d'accord!





  reply	other threads:[~1998-07-28  0:00 UTC|newest]

Thread overview: 138+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-16  0:00 Naming of Tagged Types and Associated Packages taashlo
1998-07-25  0:00 ` Matthew Heaney
1998-07-25  0:00   ` Jean-Pierre Rosen
1998-07-25  0:00     ` Brian Rogoff
1998-07-26  0:00       ` Matthew Heaney
1998-07-26  0:00     ` Matthew Heaney
1998-07-26  0:00       ` nabbasi
1998-07-26  0:00         ` Matthew Heaney
1998-07-26  0:00         ` Robert Dewar
1998-07-27  0:00       ` dennison
1998-07-27  0:00         ` Stephen Leake
1998-07-27  0:00           ` dennison
1998-07-27  0:00             ` Brian Rogoff
1998-07-28  0:00               ` dennison
1998-07-28  0:00                 ` Brian Rogoff
1998-07-28  0:00                   ` dennison
1998-07-29  0:00                     ` Matthew Heaney
1998-07-29  0:00                       ` Chris Brand
1998-07-30  0:00                         ` Matthew Heaney
1998-07-30  0:00                           ` dennison
1998-07-30  0:00                             ` Matthew Heaney
1998-07-30  0:00                               ` dennison
1998-08-01  0:00                           ` Simon Wright
1998-08-02  0:00                             ` Matthew Heaney
1998-08-03  0:00                               ` dennison
1998-08-03  0:00                                 ` Matthew Heaney
1998-08-04  0:00                                   ` dennison
1998-08-04  0:00                               ` Jean-Pierre Rosen
1998-08-04  0:00                                 ` Brian Rogoff
1998-08-05  0:00                               ` Don Harrison
1998-08-05  0:00                                 ` Matthew Heaney
1998-08-07  0:00                                   ` Don Harrison
1998-08-13  0:00                                     ` Robert A Duff
1998-08-14  0:00                                       ` adam
1998-08-14  0:00                                       ` Don Harrison
1998-08-05  0:00                                 ` Brian Rogoff
1998-08-07  0:00                                   ` doylep
1998-08-07  0:00                                     ` Brian Rogoff
1998-08-08  0:00                                       ` Matthew Heaney
1998-08-10  0:00                                       ` doylep
1998-08-10  0:00                                         ` Brian Rogoff
1998-08-10  0:00                                           ` John Volan
1998-08-10  0:00                                           ` John Volan
1998-08-11  0:00                                           ` doylep
1998-08-11  0:00                                             ` Brian Rogoff
1998-08-13  0:00                                               ` Robert A Duff
1998-08-13  0:00                                                 ` Brian Rogoff
1998-09-01  0:00                                                 ` Matthew Heaney
1998-09-01  0:00                                                   ` Dale Stanbrough
1998-09-01  0:00                                                     ` Matthew Heaney
1998-09-01  0:00                                                       ` Bob Collins
1998-09-02  0:00                                                         ` Matthew Heaney
1998-09-04  0:00                                                       ` John G. Volan
1998-08-11  0:00                                         ` Don Harrison
1998-08-11  0:00                                           ` Pat Rogers
1998-08-11  0:00                                             ` Don Harrison
1998-09-01  0:00                                               ` Matthew Heaney
1998-08-13  0:00                                         ` Robert A Duff
1998-08-13  0:00                                           ` Brian Rogoff
1998-08-15  0:00                                             ` Don Harrison
1998-08-15  0:00                                               ` Jean-Pierre Rosen
1998-08-18  0:00                                                 ` Don Harrison
1998-08-14  0:00                                           ` Don Harrison
1998-08-17  0:00                                             ` doylep
1998-08-19  0:00                                               ` Don Harrison
1998-08-12  0:00                                       ` Don Harrison
1998-08-08  0:00                                     ` Matthew Heaney
1998-08-08  0:00                                       ` John G. Volan
1998-08-09  0:00                                         ` Matthew Heaney
1998-08-10  0:00                                           ` John G. Volan
1998-08-11  0:00                                             ` John Volan
1998-08-11  0:00                                             ` Don Harrison
1998-08-11  0:00                                               ` geoff
1998-08-31  0:00                                             ` Matthew Heaney
1998-08-31  0:00                                               ` Tucker Taft
1998-09-06  0:00                                                 ` John G. Volan
1998-09-06  0:00                                                   ` Matthew Heaney
1998-09-04  0:00                                               ` John G. Volan
1998-09-05  0:00                                                 ` Matthew Heaney
1998-09-05  0:00                                                   ` John G. Volan
1998-09-04  0:00                                               ` John G. Volan
1998-09-06  0:00                                                 ` Matthew Heaney
1998-09-06  0:00                                                   ` John G. Volan
1998-09-06  0:00                                                   ` John G. Volan
1998-09-06  0:00                                                     ` Brian Rogoff
1998-09-06  0:00                                                       ` John G. Volan
1998-09-07  0:00                                                         ` Brian Rogoff
1998-09-07  0:00                                                           ` John G. Volan
1998-09-16  0:00                                                             ` Matthew Heaney
1998-09-04  0:00                                               ` John G. Volan
1998-09-05  0:00                                                 ` John G. Volan
1998-09-06  0:00                                                   ` Matthew Heaney
1998-09-06  0:00                                                 ` Matthew Heaney
1998-09-05  0:00                                               ` John G. Volan
1998-09-05  0:00                                               ` John G. Volan
1998-08-11  0:00                                       ` doylep
1998-08-07  0:00                                   ` Don Harrison
1998-08-05  0:00                           ` Static Polymorphism (Was Re: Naming of Tagged Types...) Brian Rogoff
1998-08-06  0:00                             ` Matthew Heaney
1998-08-06  0:00                               ` Brian Rogoff
1998-07-28  0:00                   ` Naming of Tagged Types and Associated Packages Brian Rogoff
1998-07-29  0:00                     ` Matthew Heaney
1998-07-29  0:00                       ` Brian Rogoff
1998-07-28  0:00             ` Norman H. Cohen
1998-07-28  0:00               ` Matthew Heaney
1998-07-28  0:00               ` Stephen Leake
1998-07-28  0:00         ` Matthew Heaney
1998-07-28  0:00           ` Jean-Pierre Rosen
1998-07-28  0:00             ` Matthew Heaney
1998-07-28  0:00               ` dennison
1998-07-29  0:00                 ` Matthew Heaney
1998-07-30  0:00                 ` Robert Dewar
1998-07-30  0:00                   ` Matthew Heaney
1998-08-06  0:00         ` Robert A Duff
1998-08-06  0:00           ` Matthew Heaney
1998-08-06  0:00             ` Tucker Taft
1998-08-31  0:00               ` Matthew Heaney
1998-07-27  0:00       ` Jean-Pierre Rosen
1998-07-28  0:00         ` Matthew Heaney [this message]
1998-07-28  0:00           ` Jean-Pierre Rosen
1998-07-28  0:00             ` dennison
1998-07-29  0:00               ` Jean-Pierre Rosen
1998-07-29  0:00                 ` dennison
1998-07-29  0:00                   ` Jean-Pierre Rosen
1998-07-30  0:00                     ` dennison
1998-07-30  0:00                       ` Jean-Pierre Rosen
1998-07-29  0:00         ` Robert I. Eachus
1998-07-30  0:00           ` Matthew Heaney
1998-07-30  0:00           ` Jean-Pierre Rosen
1998-07-30  0:00             ` Robert I. Eachus
1998-07-31  0:00               ` Jean-Pierre Rosen
1998-07-31  0:00                 ` Robert I. Eachus
1998-08-01  0:00                   ` Jean-Pierre Rosen
1998-08-04  0:00                     ` Matthew Heaney
1998-08-04  0:00                       ` Jean-Pierre Rosen
1998-08-10  0:00                         ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
1998-07-26  0:00 tmoran
1998-07-27  0:00 ` dennison
replies disabled

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