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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!news.glorb.com!news.agarik.com!194.2.0.24.MISMATCH!oleane.net!oleane!not-for-mail From: =?UTF-8?B?RmFsayBUYW5uaMOkdXNlcg==?= Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Thu, 10 Mar 2005 11:45:30 +0100 Organization: Canon Research Centre France Message-ID: References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1110329098.642196@athnrd02> <1110361741.551255@athnrd02> <422edaec$0$26554$9b4e6d93@newsread4.arcor-online.net> <422f0e39$0$26546$9b4e6d93@newsread4.arcor-online.net> NNTP-Posting-Host: centre.crf.canon.fr Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: s1.news.oleane.net 1110451515 8626 194.2.158.33 (10 Mar 2005 10:45:15 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Thu, 10 Mar 2005 10:45:15 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: de, fr, pl, en, en-us In-Reply-To: <422f0e39$0$26546$9b4e6d93@newsread4.arcor-online.net> Xref: g2news1.google.com comp.lang.ada:9022 comp.lang.c++:44934 comp.realtime:1191 comp.software-eng:4754 Date: 2005-03-10T11:45:30+01:00 List-Id: Georg Bauhaus wrote: > Falk Tannh=C3=A4user wrote: >> Such function objects can be of dedicated classes, or can be construct= ed >> "on the fly" (even it the latter possibility is sometimes a bit awkwar= d >> due to the lack of closures / lambda expressions in the language - btw= , >> does Ada have something like that?). > Ada 2005 adds downward closures. They have been available in GNAT/GCC > for a number of years now. > For pure Ada 95 there is a workaround using dispatching. >=20 > Is a function object similar to a downward closure? Well, I tried to google what Ada "downward closures" are but since I don't know the language, I'm not sure I properly understood how they work (shame on me!). An example of using a C++ standard function object to find the index of the first element in a vector being greater than 666 looks like std::vector vec; =2E.. std::vector::iterator it =3D std::find_if(vec.begin(), vec.end(),= std::bind2nd(std::greater= (), 666)); if(it =3D=3D vec.end()) std::cout << "Not found!\n"; else std::cout << "Found at index " << (it - vec.begin()) << ", value =3D= " << *it << '\n'; Of course, it would be nicer, easier and more flexible if you could write= something like (syntax totally hypothetical!): std::vector::iterator it =3D std::find_if(vec.begin(), vec.end(),= lambda{x; x>666} ); Adding something like this to C++ is currently under discussion / pre-stu= dy and it is not yet clear how the result will look like... Falk