[erlang-questions] closures and list comprehensions
Mon Feb 18 09:06:51 CET 2008
You are correct, the list comprehension will be done in the spawned
process. Everything in the fun will be done when the fun is evaluated,
which is in the new process.
On Mon, 2008-02-18 at 00:05 +0200, Harold Ship wrote:
> I'm fairly new to Erlang, and I'm just starting to get the hang of it.
> I have a question about using spawn/1, giving it a fun which is a
> closure that contains a list comprehension. The example is like this:
> my_func([First|Rest]) ->
> Me = self(),
> spawn(fun() -> Me ! do_something([X || X <- Rest, X < First]) end),
> Result ->
> My question is, in which process is the list comprehension evaluated?
> It seems to me that it should be evaluated in the spawned process but
> I can't reason it out.
> Thanks in advance,
> Harold Ship
> erlang-questions mailing list
More information about the erlang-questions