comp.lang.ada
 help / color / mirror / Atom feed
* Default value for a record component
@ 2007-07-21 21:19 Maciej Sobczak
  2007-07-22  8:08 ` Dmitry A. Kazakov
  2007-07-24  1:27 ` Randy Brukardt
  0 siblings, 2 replies; 10+ messages in thread
From: Maciej Sobczak @ 2007-07-21 21:19 UTC (permalink / 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/




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-07-24 19:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2007-07-24  1:27 ` Randy Brukardt
2007-07-24  9:54   ` Maciej Sobczak
2007-07-24 19:12     ` Randy Brukardt

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