comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Virtual Components in Ada and Ruby
Date: Thu, 30 Jun 2005 09:53:02 +0200
Date: 2005-06-30T09:53:02+02:00	[thread overview]
Message-ID: <1dvcq9fimqv12.g8zq212sn8fw$.dlg@40tude.net> (raw)
In-Reply-To: 9oadnZwlOoYa7V7fRVn-2A@megapath.net

On Wed, 29 Jun 2005 23:12:48 -0500, Randy Brukardt wrote:

> "Frank J. Lhota" <NOSPAM.lhota@adarose.com> wrote in message
> news:2ifue.819$Z97.597@trndny06...
> ....
>> Looking ahead to Ada 201Z, should there be user-defined virtual record
>> components? Currently, a component of a record must always be defined as
>> a section of memory in a record. Would it be desirable to also be able
>> to define a record component in terms of subprograms for reading and
>> writing that component?

Yes! Though this is not the complete list of what "record interface" should
do. Also:

1. Record aggregates should be support "virtual" user-defined components.
2. The most important thing is "virtual" discriminants. This would open a
great variety of possibilities.
3. Overriding non-"virtual" components with "virtual" ones and vice versa.
4. Abstract "virtual" components to be required for overriding and thus
abstract record types.

> I think it would likely be too ambiguous with other possibilities to be very
> useful.

I think that "record interface" could drastically improve Ada. Virtual
members is only a part of what should be: an ability to provide private
implementation of a record type (and also an array or an access type.)

> Certainly, Ada 200Y has "virtual record components" for reading:
> 
>     type Something is tagged record ... end record;
>     function Virtual (Obj : in Somthing) return Integer;
> 
>     Object : Something;
> 
>     if Object.Virtual = 10 then ...
> 
> But there doesn't seem to be a practical way to make them writable on the
> LHS of an assignment. A procedure call isn't too bad in that case:
>     Object.Set_Virtual (To => <args>);

Though it is unsuitable if you want, for example, pass a virtual record
type as a generic parameter.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2005-06-30  7:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-22 15:17 Virtual Components in Ada and Ruby Frank J. Lhota
2005-06-30  4:12 ` Randy Brukardt
2005-06-30  7:53   ` Dmitry A. Kazakov [this message]
2005-06-30 15:53     ` Alexander E. Kopilovich
2005-06-30 18:55       ` Randy Brukardt
2005-07-01 10:04         ` Dmitry A. Kazakov
replies disabled

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