From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,63a41ccea0fc803a X-Google-Attributes: gid103376,public From: "Jean-Pierre Rosen" Subject: Re: Naming of Tagged Types and Associated Packages Date: 1998/07/28 Message-ID: <6pk3jh$gpm$2@platane.wanadoo.fr>#1/1 X-Deja-AN: 375599110 Content-Transfer-Encoding: 8bit References: <6pdhfo$1br$1@platane.wanadoo.fr> <6pi71p$n90$1@platane.wanadoo.fr> Content-Type: text/plain; charset="iso-8859-1" X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: Adalog Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-07-28T00:00:00+00:00 List-Id: Matthew Heaney a �crit dans le message ... >"Jean-Pierre Rosen" writes: >[...] >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. Agreed, but this happens ONLY if the type and associated "methods" (primitive operations) are declared in the same package. Therefore, it's the package that turns a "type" into a "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." In this discussion, I take "class" with the conventional meaning of the OOP world. The nice thing with Ada is that its building blocks approach allows you to build various paradigms, and we are talking here about one such special paradigm. Whether naming it "OOP" and using "class" is a good idea is another issue... >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 I responded to that in an other message... >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; When you instantiate the package, all types will be named "Privileged_Account". Agreed, in this example it is not too bad, but think for example of a package that adds persistency to any tagged type: generic type Origin is tagged private; package Persistence is type Persistent is new Origin with private; ... end Persistence; Then all types to which you add persistency will be called simply "Persistent". Now, you'll tell me that it won't be a problem, since you'll use full notation. But how will you name the package ? "Persistent_Account" ? That would give Persistent_Account.Persistent. Not really pretty. And what if you have a bank account which is both Persistent and Privileged ? Depending on the order of instantiation, you would end up with either Persistent_Privileged_Bank_Account.Persistent or Persistent_Privileged_Bank_Account.Privileged_Account. This would give a special importance to the one which is instantiated last... Once again, if you don't like the name "instance", take something else, but the idea is to have a single, *neutral* name for the main type, in order to have a consistant and uniform notation. >I suppose you could just do another local type derivation, or declare a >local subtype. This was my idea when I first studied the issue, and my paper discusses why it does not work. Please have a look at it. If you don't have an archive of Ada Letters, just drop me a mail telling your preferred format, and I'll be happy to send it to you (if others in this newsgroup also want a copy, they are also welcome :-) -- ---------------------------------------------------------------------------- J-P. Rosen (Rosen.Adalog@wanadoo.fr) Visit Adalog's web site at http://perso.wanadoo.fr/adalog