comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin.dowie@btopenworld.com>
Subject: Re: 'Image for composite types
Date: Wed, 27 May 2009 23:46:53 -0700 (PDT)
Date: 2009-05-27T23:46:53-07:00	[thread overview]
Message-ID: <50e68e9b-c987-4876-8495-ad6dffe51274@t21g2000yqi.googlegroups.com> (raw)
In-Reply-To: 45845c4b-58f4-4848-8d5e-2ab58133c250@d38g2000prn.googlegroups.com

Adam,

Thanks for the comments so far...hopefully there are answers to them
that satisfy...

On May 28, 12:44 am, Adam Beneschan <a...@irvine.com> wrote:
[snip]
> This wouldn't work on variant records.

Could add these as well?

   function record_type_definition'Discriminant_Name (I : Positive)
return String;
   function record_type_definition'Discriminant_Image (I : Positive)
return String;
   function record_type_definition'Number_Of_Discriminants return
Natural;

For 'plain' records 'Number_Of_Discriminants would return 0.


> Plus, what does
> 'Component_Image return if the component type is itself another
> record, or an array, or a task?  Or an access?

Then it would call the 'Image for that component - in the same way as
for Integer or Float etc.

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

In this new extension I'm imagining that all records have at least a
compiler generated 'Image (which the user can override) with:

   type My_Record is private;
private;
   fnunction To_String (R : My_Record) return String;
   for My_Record'Image use To_String;

For access types, if I'm writing these by hand, I'd return string
"null" or call the 'Image for the component if it isn't null.


> A lot more thought would have to go into this to make it a real
> language feature.

Absolutely! That's why I'm floating the idea here rather than on Ada-
Comment.

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

Very true. But I'm pleased to see at least 1 ARG member publicly
acknowledging the problem, if not my proposed solution.

Cheers
-- Martin



  reply	other threads:[~2009-05-28  6:46 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
2009-05-28  6:46   ` Martin [this message]
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