[erlang-questions] Cleaning up code
Donald Steven
t6sn7gt@REDACTED
Thu Jan 31 21:59:12 CET 2019
Thanks everyone. I put the data in a separate module and that works (so
far) well. But I'll look into ETS tables, other processes, and other
ideas. Much appreciated.
Don
On 1/31/2019 9.30 AM, Hugo Mills wrote:
> On Thu, Jan 31, 2019 at 09:20:43AM -0500, Donald Steven wrote:
>> I need several large maps whose data will need to be accessed and
>> updated in a number of functions. I've defined them in main() just
>> to get started, but they're so extensive that they swamp the
>> readability of main(). I haven't found a way to "include" them as
>> 1) erlang won't accept simple file inclusion anywhere (like m4) and
>> 2) my attempt to define a map in an .hrl file (like a -record
>> definition), as in:
>>
>> keywords = #( ...}. or Keywords = #( ...}.
>>
>> just produces error messages. I could use m4, but ...
>>
>> Any suggestions? Thanks.
> It's not clear how you're using the data, but that sounds like
> either a ETS table, or a separate server process to manage the data in
> each map.
>
> If you're only concerned about the size of the initialisation for
> each map, then you could just define them in a function and call that
> in your main():
>
> main() ->
> Map1 = init_map1(),
> ...
>
>
> init_map1() ->
> #{a => 3, b => 4, ...}.
>
> Hugo.
>
More information about the erlang-questions
mailing list