[Insight-developers] Re: FunctionBase and const

Brad King brad.king@kitware.com
Tue, 18 Sep 2001 20:44:31 -0400 (EDT)


On Tue, 18 Sep 2001, Luis Ibanez wrote:
[snip]
> If eventually you *really* need to have
> some internal variable that change during
> the execution, and you consider that this
> variable is *not* part of the state of your
> class, you can use "mutable" when declaring
> the variable.
This is a good way of describing it.  The terminology that I've seen used
for this is "applicative", meaning that the function's value depends only
on the input values.  This is slightly different from a function with no
"side effects", which are extra operations done as part of the function
evaluation, but don't actually affect the result value (debug output, for
example).

One possible use of an internal variable that is not part of the state of
the function could be a "how many times have I been evaluated?" count for
each instance of the function object.  Such a member could be mutable
without losing the applicative property of the function.

-Brad