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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a1beac047b98caeb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-12 08:04:14 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: Why default values not taken? Date: Tue, 12 Jun 2001 11:04:14 -0400 Organization: AverStar (formerly Intermetrics) Burlington, MA USA Message-ID: <3B262F6D.BD69FB9F@averstar.com> References: NNTP-Posting-Host: nebula.burl.averstar.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 992358254 1879 141.199.8.77 (12 Jun 2001 15:04:14 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 12 Jun 2001 15:04:14 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:8610 Date: 2001-06-12T15:04:14+00:00 List-Id: "M. A. Alves" wrote: > > I want to create an object with only some components different from their > default values e.g. > > Contact_Person := new Text_Item'(Remark => US("name and email")); > > where Text_Item inherits Remark from Input_Item and adds Text, both > defaulting to Null_Unbounded_String: > > type Input_Item is tagged record > Remark: Unbounded_String; > end record; > > type Text_Item is new Input_Item with record > Text: Unbounded_String; > end record; > > Of course I get the compile error "no value supplied for component Text". > > But do I really have to supply values for all components? What is the > best idiom here? Aggregates must be complete. Default expressions for record components are only used for default initializations. I would recommend you define a "constructor" function or procedure, with an aggregate inside the subprogram. You can use defaulted parameters to minimize the amount of information a given call on the constructor needs to specify. In general, there are various good software-engineering reasons to minimize the use of aggregates outside the package where a type is defined. This pragmatic issue with defaults just reinforces the situation. > Thanks, > > -- > , > M A R I O data miner, LIACC, room 221 tel 351+226078830, ext 121 > A M A D O Rua Campo Alegre, 823 fax 351+226003654 > A L V E S P-4150 PORTO, Portugal mob 351+939354002 -- -Tucker Taft stt@avercom.net http://www.avercom.net Chief Technology Officer, AverCom Corporation (A Titan Company) Burlington, MA USA (AverCom was formerly the Commercial Division of AverStar: http://www.averstar.com/~stt)