<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Returning something from a function and passing a message are two completely different mechanisms. You can only 'return' a result from a function that has been 'called' such as:<div><br></div><div>initial_function()</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>do stuff</div><div> ....</div><div> ....</div><div> Value = call_function()</div><div> do more stuff</div><div> ....</div><div><br></div><div><br></div><div>call_function() -></div><div> do stuff</div><div> ....</div><div> ....</div><div> return value.</div><div><br></div><div>If you send a message from Process A to Process B, the only way to get anything from B to A would be to send a message back using the PID. Be careful in doing this that you don't create a situation where both processes are waiting for a message from the other in order to continue.<br><br><div>> Date: Mon, 17 Oct 2011 15:09:23 -0600<br>> From: comptekki@gmail.com<br>> To: erlang-questions@erlang.org<br>> Subject: [erlang-questions] return list or send message back<br>> <br>> I'm trying to learn how message passing works so I have a function<br>> that sends an "ls" message to another node and then when the other<br>> node receives it since "ls" is one of the matches for that it then<br>> runs a routine to list the files in a folder. Should I build a list<br>> and return the results or send a message back with the results.<br>> <br>> thanks,<br>> <br>> -wes<br>> _______________________________________________<br>> erlang-questions mailing list<br>> erlang-questions@erlang.org<br>> http://erlang.org/mailman/listinfo/erlang-questions<br></div></div> </div></body>
</html>