comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Default value for a record component
Date: Sun, 22 Jul 2007 12:44:02 -0700
Date: 2007-07-22T12:44:02-07:00	[thread overview]
Message-ID: <1185133442.532463.301960@r34g2000hsd.googlegroups.com> (raw)
In-Reply-To: <s8742iqtjqhy.1ap5zo7kmvx01.dlg@40tude.net>

On 22 Lip, 10:08, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>

> > 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.

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

No, this leaks the implementation detail (the Get_Default function) to
the public view and pollutes it. I don't want my users to even see it.

Ada needs real constructors, not just initial values.

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




  reply	other threads:[~2007-07-22 19:44 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 [this message]
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