From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,5b031d156719dbc9 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!d38g2000prn.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: 'Image for composite types Date: Wed, 27 May 2009 16:44:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: <45845c4b-58f4-4848-8d5e-2ab58133c250@d38g2000prn.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1243467862 32444 127.0.0.1 (27 May 2009 23:44:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 27 May 2009 23:44:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d38g2000prn.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6048 Date: 2009-05-27T16:44:22-07:00 List-Id: On May 27, 3:20=A0pm, Martin 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. > > =A0 =A0function record_type_definition'Component_Name (I : Positive) > return String; > =A0 =A0function record_type_definition'Component_Image (I : Positive) > return String; > =A0 =A0function 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 > =A0 =A0Example > =A0 =A0=3D=3D=3D=3D=3D=3D=3D > =A0 =A0 =A0 type Person is > =A0 =A0 =A0 =A0 =A0record > =A0 =A0 =A0 =A0 =A0 =A0 Name =A0 : Unbounded_String; > =A0 =A0 =A0 =A0 =A0 =A0 Age =A0 =A0: Natural; > =A0 =A0 =A0 =A0 =A0 =A0 Height : Float; > =A0 =A0 =A0 =A0 =A0 =A0 Weight : Float; > =A0 =A0 =A0 =A0 =A0end record;