[erlang-questions] per function/process locals
Wed May 2 16:12:12 CEST 2007
On 5/1/07, ok <> wrote:
> > I actually do this quite a bit.
> Why? Is there an example you can provide?
Sure. I wrote a Forth interpreter that had a data stack, floating
point stack, dictionary, tree simulating memory...and one more thing
that's escaping me. Most of the words in my interpreter took these 5
parameters as inputs. I could have put them in a record, but that was
uglier in my opinion.
I've also written a scripting system where I have ~10 state variables
that change often during execution. The preprocessed version is ~50%
faster than the record version, and the BEAM files were ~50% smaller.
The code is prettier, too.
> > Even just having 5 values
> > getting passed around and "updated" in a loop bugs me.
> Updating 5 variables in a C loop would bug me, most of the time.
It happens. I've written enough production C/C++ to realize I'd drive
myself crazy if I had to keep all code beautiful. (And updating 5
variables in a loop doesn't qualify is ugly, not by a long shot!)
More information about the erlang-questions