comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Default value for a record component
Date: Sat, 21 Jul 2007 14:19:17 -0700
Date: 2007-07-21T14:19:17-07:00	[thread overview]
Message-ID: <1185052757.500324.16860@22g2000hsm.googlegroups.com> (raw)

Consider:

package P is
   type T is record
      V : Integer := 5;
   end record;
end P;

Above, T.V will have 5 as a default value whenever the instance of T
is created without any explicit initialization.

I would like extend it and do this:

package P is
   type T is record
      V : Integer := Get_Default_Value;
   end record;
private
   function Get_Default_Value return Integer;
end P;

without losing any of the properties of the original solution and
without "leaking" any implementation detail to the public view. The
idea is, of course, to compute the default value at run-time, each
time the new object is created - but without touching the general
"look&feel" of the original code (so that for example Controlled is
excluded).
Is it possible?

--
Maciej Sobczak
http://www.msobczak.com/




             reply	other threads:[~2007-07-21 21:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-21 21:19 Maciej Sobczak [this message]
2007-07-22  8:08 ` Default value for a record component 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
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