Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-08-08 08:56:43

--- In boost_at_y..., John Max Skaller <skaller_at_m...> wrote:
> williamkempf_at_h... wrote:
> > Class statics result in the same thing. For that matter, block
> > statics do as well. None of these uses are "bad designs",
> Yes, I believe every single use of static variables
> and singletons is BAD DESIGN.

Well, I don't agree, and I've yet to read a book on design that does

> MAJOR systems have been stuffed because of this:
> GTK, the 3 million line program I once worked on,
> the C library, I can go on and on: people are now
> trying to fix the stupidity of the von Neumann computing
> model, but in vain. ARRGG. Doesn't anyone teach about
> good things like re-entrancy anymore?

Oh, I know about re-entrancy and it's issues, but they do *NOT*
preclude "globals" in good designs. In fact, there are several
classes of designs that simply can't be coded with out the use of
global data.
> > and every langauge I'm aware of supports at least one of these
> > of "global" data.
> Pascal, Modula, Eiffel.

Depends on what you mean here. Been too long since I did Pascal, but
I believe it had an answer for this issue. Never touched Modula, so
I can't speak to it. Eiffel I'm a tad more familiar with in the
recent past, so I can prove you wrong right now. This is what
the "once" feature is used for.

Even a construct as simple as (pseudo code for any language):

main() // or language equivalent
   foo global_foo;
   bar(global_foo); // pass to all routines/objects that need
                    // the global data

Results in "global" data with the same re-entrancy issues. The only
difference is that this harder to code to construct *may* point out
misuse in the code if you know which routines have re-entrant

Re-entrancy issues reveal problems with _shared_ data, not problems
with global data, class statics or block statics. The solutions to
the problem are the same no matter the form of the shared data. To
claim that "global" data is a bad design because of re-entrancy must
logically follow that designs using shared data are bad designs as
well. If that were the case then 90% of Boost.Threads would be
pointless, since no valid design would ever have a use for it.

Bill Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at