comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: 'Image for composite types
Date: Wed, 27 May 2009 16:44:22 -0700 (PDT)
Date: 2009-05-27T16:44:22-07:00	[thread overview]
Message-ID: <45845c4b-58f4-4848-8d5e-2ab58133c250@d38g2000prn.googlegroups.com> (raw)
In-Reply-To: f241da28-497c-450a-a804-829eaa1f7608@l28g2000vba.googlegroups.com

On May 27, 3:20 pm, Martin <martin.do...@btopenworld.com> wrote:
> Is it just me that gets fed up with the lack of 'Image on composite
> types?
>
> I'm thinking in particular of when I'm testing / debugging and usually
> end up writing lots of 'Put_Line' code for each and every record. And
> then having to maintain them.
>
> It got me thinking that the language could be expanded to include some
> helper attributes for easily composing a function that could return a
> String a la 'Image for scalar types.
>
>    function record_type_definition'Component_Name (I : Positive)
> return String;
>    function record_type_definition'Component_Image (I : Positive)
> return String;
>    function record_type_definition'Number_Of_Components return
> Natural;

This wouldn't work on variant records.  Plus, what does
'Component_Image return if the component type is itself another
record, or an array, or a task?  Or an access?

Plus, in your example below, one of your components is an
Unbounded_String, which is a private type most likely implemented as a
record or access type.  What language rule would make 'Component_Image
of that type return the string value, while 'Component_Image of other
records or access types would do something more pedestrian?

A lot more thought would have to go into this to make it a real
language feature.  Others may have opinions on whether the amount of
effort required to design this feature well, combined with the amount
of effort required for compiler vendors to implement it, is justified
by the benefits.

                                    -- Adam


>    Example
>    =======
>       type Person is
>          record
>             Name   : Unbounded_String;
>             Age    : Natural;
>             Height : Float;
>             Weight : Float;
>          end record;



  parent reply	other threads:[~2009-05-27 23:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-27 22:20 'Image for composite types Martin
2009-05-27 23:23 ` Robert A Duff
2009-05-27 23:44 ` Adam Beneschan [this message]
2009-05-28  6:46   ` Martin
2009-05-28  9:53   ` Georg Bauhaus
2009-05-28 10:42     ` Martin
2009-05-28 11:31       ` Georg Bauhaus
2009-05-28 16:25       ` Jeffrey R. Carter
2009-05-28 16:47         ` Martin
2009-05-28  3:36 ` Per Sandberg
2009-05-28  5:15   ` tmoran
2009-06-06  9:17   ` Martin
2009-05-28  9:13 ` Dmitry A. Kazakov
2009-05-31 12:17 ` Stephen Leake
2009-06-06  9:17   ` Martin
replies disabled

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