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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,196864e6c216ca4f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-25 09:11:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!elnk-nf2-pas!newsfeed.earthlink.net!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!rwcrnsc53.POSTED!not-for-mail Message-ID: <3F7313BD.2050602@attbi.com> 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: <3F722C53.9020808@attbi.com> <5917f4d0.0309250459.59940bc9@posting.google.com> 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: rwcrnsc53 1064506305 24.34.139.183 (Thu, 25 Sep 2003 16:11:45 GMT) NNTP-Posting-Date: Thu, 25 Sep 2003 16:11:45 GMT Organization: Comcast Online Date: Thu, 25 Sep 2003 16:11:45 GMT Xref: archiver1.google.com comp.lang.ada:42904 Date: 2003-09-25T16:11:45+00:00 List-Id: Tad Ashlock wrote: > I've been trying ideas along these lines for a few days, but I haven't > been able to make them work. I understand how the procedure would get > created, but I don't understand where the data is uniquely cached for > each procedure call. (The C++ implementation above does it in t_->data.) >> type Subprogram_Record is record >> SP: Subprogram_Pointer; -- Put whatever else you want right here. Just like in the C++ there has -- to be a local modifiable object of this type to make the call. >> end record; > I'm not following this one at all. Where is the cached data? As I said, it goes in the record with the access value. The caller has to declare a local copy to make a call, and that stores the data. I much prefer the more Ada-like abstraction where the user instantiates a generic, and the generic has both local data and a (local) instance of the subroutine. > Thank you so much, Robert, for taking the time to reply to my question. It is an interesting question, and as a result I may actually advocate a language change. If we had the equivalent of access discriminants for Ada subprograms, this would be much cleaner. I think that the right level of implementation is an attribute. So that Some_Subprogram'Called_From gets you the called from address. It is not the best solution for this problem, but there may be a way to define it to be useful in doing stack tracebacks. (Which argues for the system programming annex.) -- Robert I. Eachus Ryan gunned down the last of his third white wine and told himself it would all be over in a few minutes. One thing he'd learned from Operation Beatrix: This field work wasn't for him. --from Red Rabbit by Tom Clancy.