Constant lists
James Hague
jhague@REDACTED
Mon Jun 26 05:06:16 CEST 2000
In Erlang, if you want to have a constant, medium-sized list, what's the
best way of dealing with it? In Lisp, for example, you use defparameter
to define a list and then reference it when you need it.
In Erlang, you could do this:
constant_list() -> [item1, item2, item3, item4, ...].
but then that list is actually created each time you call it, which is
messy. It's not really a constant in this case. For association lists,
you could code it in a Prolog style:
name(john) -> 7;
name(bjorn) -> 3;
name(james) -> 9.
but this isn't general. Or, you could read the term from disk, but then
only the current process has access to it. Putting it in a global ets
table results in the list being copied each time it is fetched.
Sure would be nice to have honest-to-goodness constant lists and tuples.
Any thoughts?
James
More information about the erlang-questions
mailing list