4 ms·
With Erlang, a similar effect could be achieved with the process dictionary: > erlang:put(1,1). undefined > erlang:get(1). 1 > erlang:put(1,erlang:ge
by mononcqc 17y ago
With Erlang, a similar effect could be achieved with the process dictionary:
> erlang:put(1,1).
undefined
> erlang:get(1).
1
> erlang:put(1,erlang:get(1)+1).
1
> erlang:get(1).
2
> erlang:put(2,3).
undefined
> erlang:get().
[{1,2},{2,3}]
It's limited to a single process and thus doesn't break the 'no-shared-memory' model. It also lets you access and modify data without copying it, so the closest implementation of such a function would need to be defined that way and would only return the final list.
Of course, this breaks the idea of 'purely functional' which is what the author found problematic.