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,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!in.100proofnews.com!in.100proofnews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: 14 Mar 2005 15:22:22 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110377260.350158.58730@z14g2000cwz.googlegroups.com> <1136bh3li136dac@corp.supernews.com> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1110831743 18656 69.38.147.31 (14 Mar 2005 20:22:23 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 14 Mar 2005 20:22:23 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:9384 comp.lang.c++:45649 comp.realtime:1465 comp.software-eng:5032 Date: 2005-03-14T15:22:22-05:00 List-Id: CTips writes: > Robert A Duff wrote: > > > Kilgallen@SpamCop.net (Larry Kilgallen) writes: > > > >>Even Bliss has nested functions. What Ada has that Pascal has in addition > >>to nested functions is uplevel addressing, allowing an inner function to > >>access data declared in outer scopes. > > Heh? Pascal has that. In fact, practically every programming language > > outside the C family has this feature. It's quite useful -- almost > > essential in multi-threaded programs. > > - Bob > > Yeah, and don't ask what it costs you. I'd carefully forgotten about all > the grungy details about displays and static/dynamic chaining, and you > had to remind me. I particularily like solutions that reserves a > register for the top-of-display/top-of-static-chain. Thats right - blow > away a register for that. And then of course the cost of > maintaining/walking those structures. I beg to differ. Uplevel references can be implemented as efficiently as parameter passing (which is what you normally do in C-family languages as a substitute). And it can cost nothing when not used. It can also cost nothing when the procedures involved can be inlined (which is a very common case -- the reason I'm writing a nested procedure is usually so I can pass it to an iterator, and both the iterator and the nested procedure are usually small enough to deserve inlining). (I'm not a big fan of displays, by the way.) > If you need thread-private storage, there are *much* cheaper solutions. This seems like a nonsequitor -- thread-private storage and uplevel references are different things, with different (though somewhat related) purposes. C and C++ have neither, which can make using thread packages painful, though gcc supports uplevel references (for both C and Ada, and I think C++ also). And having implemented both, I'd say thread-private storage is generally more expensive than uplevel references. What's your much cheaper solution? - Bob