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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC 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-7-bit Received: by 10.68.35.68 with SMTP id f4mr18328231pbj.5.1322365022692; Sat, 26 Nov 2011 19:37:02 -0800 (PST) MIME-Version: 1.0 Path: lh20ni22493pbb.0!nntp.google.com!news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news-transit.tcx.org.uk!aioe.org!.POSTED!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Overloading attributes Date: Sun, 27 Nov 2011 03:36:59 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <8ed87fee-166a-4be9-ae6c-4d0fbeb4788c@s6g2000vbc.googlegroups.com> Reply-To: anon@anon.org NNTP-Posting-Host: 6ile/woNr5qq8BK9Zv2iCw.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: IBM NewsReader/2 2.0 Xref: news2.google.com comp.lang.ada:14670 Date: 2011-11-27T03:36:59+00:00 List-Id: In Ada, Overloading is allow for all attributes include programmers created attributes. But Adacore GNAT has decided a number of years ago to not allow programmers to create their attributes and has limited the overloading of standard attributes. While some may see this as cripping Ada others do not. Because except for those predefined by the Ada standard library which may be hidden, the programmer create attribute routine rather overloading or not must be visable to the package it is used in. So, its just as reasonable to call the attribute routine as any other routine. Note: Other Ada compilers may or may not follow Adacore GNAT decision on this issue. In <8ed87fee-166a-4be9-ae6c-4d0fbeb4788c@s6g2000vbc.googlegroups.com>, Matt Borchers writes: >Why is it that one cannot overload the 'Image and 'Value attribute >similar to how we can overload 'Input, 'Output, 'Read, and 'Write? I >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? Why 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; --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 := 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? Could >they be overloaded on user-defined types?