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/31 Message-ID: <6ps2ne$hko$1@platane.wanadoo.fr>#1/1 X-Deja-AN: 376623098 Content-Transfer-Encoding: 8bit References: <6pdhfo$1br$1@platane.wanadoo.fr><6pi71p$n90$1@platane.wanadoo.fr><6ppc3q$8ju$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-31T00:00:00+00:00 List-Id: Very interesting, I think we are progressing... Robert I. Eachus a �crit dans le message ... > A VERY simplified example: > > with Ada.Finalization; > package People is > > type Person is tagged private; > > function Name(Who: in Person) return String; > procedure Set_Name(Who: in out Person; Name: in String); > function Address(Who: in Person) return String; > function Set_Address(Who: in out Person; Address: in String); > ... > > private > > package Add_Name is new Unbounded_String_Component( > Ada.Finalization.Controlled); > package Add_Address is new Unbounded_String_Component( > Add_Name.Record_Type); > type Person is new Add_Address.Record_Type with null; > > pragma Inline(Name, Set_Name, Address, Set_Address); > > end People; > > Now in the body I'll have to write things like: > > function Name(Who: in Person) return String is > begin return Add_Name.Get(Who); end Name; Your example is excellent, because you declare a *private* tagged type, and export its operations explicitely. But pragma Disclaimer (on); I do think, and often claim, that one of the big advantages of Ada over other OO languages is that you can use inheritance at *implementation* level without using it at specification level; or (like here) have hidden inheritances, that allow you to break the transitive dependence. I have therefore much sympathy for the way the example is written; however, we are discussing naming of classes in the general case here, in the context of "traditionnal" OO style. pragma Disclaimer (off); if you want to *visibly* add a facet, then it wouldn't work so easily (once again, look at the example in the paper). Why would you want to add visibly a facet ? Because this way, if you add new operations to a facet, they are immediately inherited by all users. If you instantiate privately, you'll have to add new "interface" routines to all packages. Granted, this is better from the point of view of encapsulation, but not from the point of view of flexibility. And the "pure OOP" approach is most effective in cases where flexibility is considered more important than encapsulation (but this is another debate). ---------------------------------------------------------------------------- J-P. Rosen (Rosen.Adalog@wanadoo.fr) Visit Adalog's web site at http://perso.wanadoo.fr/adalog