Records, encapsulation and optional elements
Ulf Wiger
etxuwig@REDACTED
Tue May 21 17:30:27 CEST 2002
On Tue, 21 May 2002, Alex Peake wrote:
>It seems, then, that there is a trade-off between the compact,
>elegant code solutions that you suggest and my clumsy attempt:
>
>* Your solutions involve copying the record several times before
> completion
True, but for small records, this is hardly detectable.
The VM will have a hard time optimizing away the copying, since
we're setting one value at a time. For a huge record (=very large
number of attributes), this might be a problem, but normally it's
insignificant.
>* My solution looks ugly (and creates lots of intermediate
> variables)
I don't think the number of intermediate variables is a problem,
but your code makes lots of passes with lists:keysearch/2 through
the Options list. This will most likely be more expensive than
the record copying above.
/Uffe
--
Ulf Wiger, Senior Specialist,
/ / / Architecture & Design of Carrier-Class Software
/ / / Strategic Product & System Management
/ / / Ericsson Telecom AB, ATM Multiservice Networks
More information about the erlang-questions
mailing list