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: 103376,73cb216d191f0fef X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.8.4 with SMTP id n4mr8272395wia.0.1363298465713; Thu, 14 Mar 2013 15:01:05 -0700 (PDT) MIME-Version: 1.0 X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63 Path: bp2ni92426wib.1!nntp.google.com!proxad.net!feeder1-2.proxad.net!nntpfeed.proxad.net!news.muarf.org!news.ecp.fr!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Thu, 14 Mar 2013 17:01:03 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <8klywqh2pf$.1f949flc1xeia.dlg@40tude.net> <513f6e2f$0$6572$9b4e6d93@newsspool3.arcor-online.net> <513faaf7$0$6626$9b4e6d93@newsspool2.arcor-online.net> <51408e81$0$6577$9b4e6d93@newsspool3.arcor-online.net> <11rcs3gg4taww$.bylek8fsshyz$.dlg@40tude.net> <99929f93-b80f-47c3-8a37-c81002733754@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1363298465 6592 69.95.181.76 (14 Mar 2013 22:01:05 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 14 Mar 2013 22:01:05 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2013-03-14T17:01:03-05:00 List-Id: "Shark8" wrote in message news:99929f93-b80f-47c3-8a37-c81002733754@googlegroups.com... > On Wednesday, March 13, 2013 3:09:24 PM UTC-6, Randy Brukardt wrote: ... >> The not-defined procedure 'Succ would have been much more useful because >> it >> could replace expressions like: >> >> := + 1; >> with >> 'Succ; >> >> which would eliminate the potential for errors, possibly generate better >> code (by not having to evaluate twice if it contains >> function calls), and eliminate the hair-brained calls for ":=+" operators >> (which don't even work for Ada). >> > > Would there be a problem using this? > > Generic > Type T is (<>); > with function Succ(Input : T) Return T is T'Succ; > package Test is > -- Body does whatever is needed requiring Very_Long_Name as T. > end Test; I don't see how this would work. You need to be able to use it on multiple s in order to make it worth the effort. Something like: generic type T is (<>); procedure Succ (Obj : in out T; Count : in Natural := 1) is -- Note: I know this requires a separate spec! begin for I in 1 .. Count loop Obj := T'Succ(Obj); end loop; end Succ; would match the intended attribute semantically. But it doesn't help much, because you have to write the generic somewhere, and then you have to instantiate it when you need it as well. That's not very helpful for what is intended to be a short-cut (you usually would end up typing more). The big advantage of an object attribute (like this 'Succ or GNAT's 'Img) is that you don't have to figure out the nominal subtype of the object to increment it once (which you do to write an instance of my Succ generic). Randy.