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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,196864e6c216ca4f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-29 19:45:30 PST Path: news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3F78EE34.9090902@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to Emulate C++ Macro with Static Local Variable? References: <3F73107A.1060502@attbi.com> <04Hcb.577973$Ho3.106182@sccrnsc03> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc52.ops.asp.att.net 1064889929 24.34.139.183 (Tue, 30 Sep 2003 02:45:29 GMT) NNTP-Posting-Date: Tue, 30 Sep 2003 02:45:29 GMT Organization: Comcast Online Date: Tue, 30 Sep 2003 02:45:29 GMT Xref: news1.google.com comp.lang.ada:280 Date: 2003-09-30T02:45:29+00:00 List-Id: taashlo@sandia.gov wrote: > Although I originally thought that the C++ implementation was a bit of a > hack, I'm beginning to think that this is a somewhat elegant solution to > a problem that can't be elegantly solved in Ada. By elegant, in this > case, I mean simple, extensible, and maintainable. Remember that the code I posted was more of an existance proof rather than an elegant implementation of what you were asking for. I could probably come up with a version that hid away most of the details from a user, but I wanted it to be possible to see what was going on. Having said that, the general Ada solution to this type of problem is generics. Generics allow you to have two points at which variables are bound to parameters, which allows for a much greater richness of application than the C++ code. The flip side of that is that the C++ code is simpler. In Ada you can have one memo per call site, in C++ you must. Which is better? What do you want to do? The Ada approach is more general, but the cost is writing a bit more per call. As for the (very gory as submitted) version I posted, I think that a return address attribute if available would be much better. You are free to add it to GNAT, or more to the point write a Return_Address function and just use that. Of course, such a function would not be portable, which is why I think that an attribute, possibly in Annex C would be a the best approach. In fact, if someone wants to propose an Ada.Call_Stack package for Ada 0Y, I'd vote for it. However, I am much more likely to try writing the package (for at least one GNAT version) first, and I suspect that the ARG as a whole would not vote for it this time around. (It is very late in the game.) -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig