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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-27 05:30:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!peernews-us.colt.net!newsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!cyclone.swbell.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail From: Wes Groleau Reply-To: wesgroleau@despammed.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en,es-MX,es,pt,fr-CA,fr MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. References: <1041908422.928308@master.nyc.kbcfp.com> <1041997309.165001@master.nyc.kbcfp.com> <1042086217.253468@master.nyc.kbcfp.com> <1042477504.547640@master.nyc.kbcfp.com> <3E32B5C0.5090004@attbi.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 27 Jan 2003 08:29:38 -0500 NNTP-Posting-Host: 151.168.133.155 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1043674205 151.168.133.155 (Mon, 27 Jan 2003 07:30:05 CST) NNTP-Posting-Date: Mon, 27 Jan 2003 07:30:05 CST Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:33453 Date: 2003-01-27T08:29:38-05:00 List-Id: > ..... A classic example of using this > binding occurs with sorts: > > [snip] > > generic > type Element is private; > type Element_Array is array (Integer range <>) of Element; > function ">" (L,R: Element) return Boolean is <>; > procedure Sort(EA: in out Element_Array); > > The 'is <>' allows the function ">" to be defaulted and left out of the > instantiation. This is where the magic--or snakepit--occurs, depending > on whether you are a user or implementor. Instead of 'is <>' I could > have written 'is Standard.">"' and ensured that the default would be to > the predefined greater than operation for Integer. Well, almost. You'd have to change "private" to "range <>" to avoid a message like: Standard.">" has no definition that matches function ">" (L, R : Element) return Boolean [RM_95 8.5.4(4)] > > Now an instantiation of Sort passing "<" instead of ">" will sort in > descending instead of ascending order. Of course for convenience, the > specification above is normally written as: > > But with the 'is <>', I get the ">" function for Integer visible at the > point of instantiation. This can be in a nested call, and the binding > can actually be to some ">" in a (run-time) enclosing declarative part. > In other words, implementing the 'is <>' notation correctly requires > support for upward closures. But there is worse (from an implementors > point of view) to come. > > The fourth point of binding is at the call. This is where the names of > the formal parameters are bound to the actuals. But notice that the > environment of the call need not be that of instantiation, in fact, > quite often it is not. This means that if you try to implement Ada > using displays, generics sometimes require passing multiple displays as > implicit parameters. (Ouch! Ask Randy Brukardt for details, he has > actually implemented it.) > > Should you use this Lisp style richness of closures when programming in > Ada? I have found very few cases where the power was worth the > documentation effort to make sure any maintainers understood what was > going on. The one exception has been in displaying appropriate error > messages during debugging of parsers. ;-) >