[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
Fluid Variable enhancements
- To: <xtech>
- Subject: Fluid Variable enhancements
- From: Mark S. Miller <mark>
- Date: Tue, 8 May 90 18:19:36 PDT
I've fixed the fluid variable package in a mostly upwards compatable
fashion. The changes are:
/*=======================================================================
|
| DEFINE_FLUID(varName) -- DEFINE_FLUID is to DESIGN_FLUID
| as DEFINE_CLASS is to CLASS
| except that type isn't repeated
| Invokes 0-parameter constructor to initialize the variable's
| storage. Initialization happens at the time the fluid space
| is created--Fluid initialization time.
|
=======================================================================*/
Programs which using DEFINE_FLUID on objects (as opposed to primitive
data types) were virtually guarateed of having undefined run-time
behavior (since the variable would never have been constructed in the
storage it was considered to have occupied). Now the object will get
properly initialized. The one non-upwards compatability is if you are
doing a DEFINE_FLUID on an object which has no 0-parameter
constructors. Now you will get a compile time error (instead of
inexplicable run-time behavior). On the other hand, if you want to
parameterize the initialization:
/*=======================================================================
|
| BUILD_FLUID(varName,initExpr) -- BUILD_FLUID is like DEFINE_FLUID
| except that the storage is initialized by using the object's
| 1-parameter constructor passing (initExpr) as the one argument.
| (initExpr) is also evaluated at fluid initialization time.
| Given the constraints of fluid initialization time, one should
| typically initialize fluids to simple constants (like IntegerVar0
| or NULL).
|
=======================================================================*/
What's this new "Fluid Initialization Time" you ask?
/********************************************************************
Fluid Initialization Time
Fluid initialization time is when the space for fluids storage gets
allocated, and when all the fluids which live in that space get
initialized. There is a global fluids space, and a per-session
fluids space. (The global fluids space can be considered to be
the space for the "main-session".) Fluid initialization time
must happen after static initialization time, but may happen
before, during, or after dynamic initialization time. The global
space gets initialized on first use of a fluid, so dynamic initialers
can safely use fluids, but fluid initializers can only safely assume
static initialization. Fluid initialization for each session happens
as part of the act of creating the session.
********************************************************************/
And finally, something I believe is already defined by some system
header file. I couldn't find it so I redid it myself (I needed it for
the above):
/*=======================================================================
|
| Invoked as "new (p) Foo (...)" in order to get the storage pointed
| to by p to be initialized to contain a Foo. Taken verbatim from
| page 31 of "The Evolution of C++: 1985 to 1989" by Bjarne. See
| discussion there
|
======================================================================*/
extern void * operator new (size_t size, void * p);