<div dir="ltr">I just had a quick look at the relevant source code (maint from GitHub).<div>Indeed, spawn_opt/3 simply calls spawn_opt/5 via erlang:apply/2, so all the limitations of spawn_opt/5<br>are also valid for spawn_opt/3. See:</div><div><br></div><div><a href="https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2405">https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2405</a><br></div><div><br></div><div>Note that when you use node() as the first argument, the code path is different and spawn_opt/2 is called instead, so you can use 'monitor' there:</div><div><br></div><div><a href="https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2403">https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2403</a></div><div><br></div><div>Interesting how you can still use a tuple-fun in spawn_opt/X. I thought tuple funs were removed in R16.</div><div><br></div><div><a href="https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2407">https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2407</a><br></div><div><br><div>Regarding execution of funs in remote nodes, here is a nice reading:</div><div><br></div><div><a href="http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html">http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html</a><br></div><div><br></div><div>Roberto</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 23 February 2015 at 16:17, Roger Lipscombe <span dir="ltr"><<a href="mailto:roger@differentpla.net" target="_blank">roger@differentpla.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm attempting to use spawn_opt/3 with a remote node, like this:<br>
<br>
Fun = fun() -> ok end,<br>
{Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]).<br>
<br>
It fails with:<br>
<br>
{badarg,<br>
[{erlang,spawn_opt,<br>
['imp_server@roger-pc',erlang,apply,<br>
[#Fun<erl_eval.20.80484245>,[]],<br>
[link,monitor]],<br>
[]}<br>
<br>
Now, the documentation at<br>
<a href="http://www.erlang.org/doc/man/erlang.html#spawn_opt-5" target="_blank">http://www.erlang.org/doc/man/erlang.html#spawn_opt-5</a> says that the<br>
'monitor' option is not allowed for spawn_opt/5. It says nothing about<br>
spawn_opt/3.<br>
<br>
Looking at the error message, it looks like spawn_opt/3 simply calls<br>
spawn_opt/5. Does this note about 'monitor' being unsupported need to<br>
be in documentation for both functions?<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Roberto Aloi<br>---<br>Website: <a href="http://roberto-aloi.com" target="_blank">http://roberto-aloi.com</a><br>Twitter: @robertoaloi<br></div>
</div>