Constant lists
Klacke
klacke@REDACTED
Mon Jun 26 09:52:19 CEST 2000
On Mon, Jun 26, 2000 at 07:57:59AM +0200, Torbjorn Tornkvist wrote:
>
> > In Erlang, you could do this:
> >
> > constant_list() -> [item1, item2, item3, item4, ...].
>
> Or this:
>
> -define(CONSTANT_LIST, [item1, item2, item3, item4, ...] ).
>
> ...
> X = ?CONSTANT_LIST,
> ...
Which ain't that good either since it will also recreate
the list every time the macro is used.
No I suggest using the dictionary,
new_const_list() -> [1,2,3,4,5,6,7].
const_list() ->
case get(const_list) of
undefined ->
N = new_const_list(),
put(const_list, N),
N;
List ->
List
end.
/klacke
--
Claes Wikstrom <klacke@REDACTED>
Bluetail AB http://www.bluetail.com
More information about the erlang-questions
mailing list