From: "Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org>
Subject: Re: Default value for a record component
Date: Sun, 22 Jul 2007 20:01:59 GMT
Date: 2007-07-22T20:01:59+00:00 [thread overview]
Message-ID: <XIOoi.19194$Xa3.11661@attbi_s22> (raw)
In-Reply-To: <s8742iqtjqhy.1ap5zo7kmvx01.dlg@40tude.net>
On Sat, 21 Jul 2007 14:19:17 -0700, Maciej Sobczak wrote:
>
> package P is
> type T is record
> V : Integer := Get_Default_Value;
> end record;
> private
> function Get_Default_Value return Integer;
> end P;
If your function is not very complicated, you can do something like
package P is
Default_Value : constant Integer;
type T is record
V : Integer := Get_Default_Value;
end record;
private
Default_Value : constant Integer := 5;
end P;
If this won't work, and your intention is to keep P's clients from
seeing the function, then you'll have to use a private type:
package P is
type T is private;
procedure Put (Into : out T; Value : in Integer);
function Get (From : in T) return Integer;
private
function Get return Integer;
type T is record
V : Integer := Get;
end record;
end P;
--
Jeff Carter
"I'm a kike, a yid, a heebie, a hook nose! I'm Kosher,
Mum! I'm a Red Sea pedestrian, and proud of it!"
Monty Python's Life of Brian
77
next prev parent reply other threads:[~2007-07-22 20:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-21 21:19 Default value for a record component Maciej Sobczak
2007-07-22 8:08 ` Dmitry A. Kazakov
2007-07-22 19:44 ` Maciej Sobczak
2007-07-22 21:44 ` Robert A Duff
2007-07-23 19:17 ` Maciej Sobczak
2007-07-23 19:41 ` Dmitry A. Kazakov
2007-07-22 20:01 ` Jeffrey R. Carter [this message]
2007-07-24 1:27 ` Randy Brukardt
2007-07-24 9:54 ` Maciej Sobczak
2007-07-24 19:12 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox