comp.lang.ada
 help / color / mirror / Atom feed
From: ANH_VO@udlp.com
To: comp.lang.ada@ada.eu.org
Subject: Re:Why default values not taken?
Date: Tue, 12 Jun 2001 11:13:00 -0500
Date: 2001-06-12T11:13:00-05:00	[thread overview]
Message-ID: <mailman.992370025.3953.comp.lang.ada@ada.eu.org> (raw)

Do not use aggregate since completion is required. The simplest way is to use
dot notation. 

declare
    Contact_Person := new Text_Item;
begin
  Contact_Persion.Remark := US("name and email");
end

Anh Vo

____________________Reply Separator____________________
Subject:    Why default values not taken?
Author: "M. A. Alves" <maa@borba.ncc.up.pt>
Date:       6/12/01 3:53 PM

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?

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




                 reply	other threads:[~2001-06-12 16:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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