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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9544fb5ce0a6df8b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.36.6 with SMTP id m6mr17516961pbj.4.1322349849207; Sat, 26 Nov 2011 15:24:09 -0800 (PST) Path: lh20ni21830pbb.0!nntp.google.com!news2.google.com!postnews.google.com!b32g2000yqn.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Overloading attributes Date: Sat, 26 Nov 2011 15:24:08 -0800 (PST) Organization: http://groups.google.com Message-ID: <3f86a446-77f5-44a1-be27-ecb8ce8ba9dd@b32g2000yqn.googlegroups.com> References: <8ed87fee-166a-4be9-ae6c-4d0fbeb4788c@s6g2000vbc.googlegroups.com> NNTP-Posting-Host: 24.230.151.194 Mime-Version: 1.0 X-Trace: posting.google.com 1322349849 20644 127.0.0.1 (26 Nov 2011 23:24:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 26 Nov 2011 23:24:09 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b32g2000yqn.googlegroups.com; posting-host=24.230.151.194; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) Xref: news2.google.com comp.lang.ada:14669 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-11-26T15:24:08-08:00 List-Id: On Nov 26, 5:13=A0pm, Matt Borchers wrote: > Why is it that one cannot overload the 'Image and 'Value attribute > similar to how we can overload 'Input, 'Output, 'Read, and 'Write? =A0I > think it would be nice to be able to do the following: > > type FOO is ...; > > function Image( f : FOO ) return String; > for FOO'Image use Image; > > function To_Foo( s : String ) return FOO; > for FOO'Value use To_Foo; > > Is there a reason that this is not allowed? =A0Why limit 'Image and > 'Value to only scalar types. > Why expose a routine to "stringify" an object through the package > specification when a language construct already exists that could do > this? > > I can also imagine how overloading 'Pred and 'Succ would be kinda nice > for link list traversals (and possibly other linked structures): > > type A_FOO is access FOO; =A0--FOO has a field that points to next > record via pointer > > function Succ( f : A_FOO ) return A_FOO; > for A_FOO'Succ use Succ; > --similar for 'Pred if it is a doubly linked list > > x : A_FOO; > x :=3D x'Succ; > > Why expose a Next routine through the package specification when a > language construct already exists that can do this? > > How about other Attributes like 'Pos, 'Val, 'First, 'Last, etc? =A0Could > they be overloaded on user-defined types? You can write an function to replace 'Image, it's a rather a good question you bring up because it can also be stated: "why are 'Read & 'Write required to have an attribute definition clause, but 'Image is not (in fact it is forbidden)?"