From: Stephen Leake <Stephe.Leake@nasa.gov>
Subject: Re: How to Emulate C++ Macro with Static Local Variable?
Date: 25 Sep 2003 09:43:31 -0400
Date: 2003-09-25T13:46:21+00:00 [thread overview]
Message-ID: <ud6dp0yrg.fsf@nasa.gov> (raw)
In-Reply-To: rgtcb.969$kD3.890@nwrdny03.gnilink.net
Hyman Rosen <hyrosen@mail.com> writes:
> Robert I. Eachus wrote:
> > This code is a bit ugly, but it does compile. And since Bar_Pointer
> > is a constant, you can't accidently pass it to Test. There might be
> > a cleaner cleverer way to do it, but this works.
> > The cleanest option may be to run your code through a preprocessor
> > and use a similar macro.
>
> Robert, I'm almost ashamed of you! You're abandoning your Ada ways
> and starting to think like a C++ hacker! :-)
AMEN!
> The whole design is wrong in the C++ to begin with. If you want to
> have a memoizing function, the job of caching old values belongs to
> the function itself, not scattered in macros and variables all over
> the place.
Yes, that is probably the best way. Although it may be that the state
should be preserved at a higher level; depends on the details.
> In Ada, I suppose that I would just stick bar(foo:integer) into a
> package, then have one of the Charles maps in the same package to
> hold memoized values.
The C code did not dynamically allocate memo state, but that is
certainly a reasonable improvement.
--
-- Stephe
next prev parent reply other threads:[~2003-09-25 13:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-24 22:06 How to Emulate C++ Macro with Static Local Variable? taashlo
2003-09-24 23:44 ` Robert I. Eachus
2003-09-25 3:27 ` Hyman Rosen
2003-09-25 4:53 ` tmoran
2003-09-25 15:57 ` Robert I. Eachus
2003-09-25 19:09 ` tmoran
2003-09-29 14:57 ` taashlo
2003-09-29 18:12 ` Jeffrey Carter
2003-09-29 18:51 ` taashlo
2003-09-30 1:32 ` Jeffrey Carter
2003-09-30 1:54 ` tmoran
2003-09-30 13:02 ` taashlo
2003-09-30 20:25 ` Jeffrey Carter
2003-09-30 2:45 ` Robert I. Eachus
2003-09-30 3:24 ` tmoran
2003-09-25 13:43 ` Stephen Leake [this message]
2003-09-25 12:59 ` Tad Ashlock
2003-09-25 16:11 ` Robert I. Eachus
2003-09-25 18:13 ` Randy Brukardt
2003-09-25 23:40 ` Robert I. Eachus
2003-09-25 11:54 ` Gautier
2003-09-25 16:14 ` Robert I. Eachus
2003-09-25 18:06 ` Tad Ashlock
2003-09-28 8:42 ` Gautier Write-only
2003-09-28 20:06 ` Jeffrey Carter
2003-09-29 2:13 ` Gautier Write-only
2003-09-25 13:41 ` Stephen Leake
2003-09-25 17:23 ` Tad Ashlock
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox