<font face="verdana,sans-serif">Hi all,</font><div><font face="verdana,sans-serif"><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="verdana, sans-serif">Today I've run into a new (to me, at least :P) <i>tricky situation</i> in escript.</font></div>
<div><font face="verdana, sans-serif">Check the following script:</font></div><div><font face="verdana, sans-serif"><br></font></div><div><div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<font face="'courier new', monospace">#!/usr/bin/env escript</font> </blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">add1(</span><span class="s1" style="font-family: 'courier new', monospace; ">X</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">) -></span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> </span><span class="s1" style="font-family: 'courier new', monospace; ">X</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> </span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">+</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> </span><span class="s4" style="font-family: 'courier new', monospace; ">1</span><span class="s5" style="font-family: 'courier new', monospace; ">.</span><font face="'courier new', monospace"><br>
</font><font face="'courier new', monospace">main(_Args) -> lists:map(fun add1/1, lists:seq(1,10)).<br></font></blockquote></div><div><font face="verdana, sans-serif"><br></font></div></div><div><font face="verdana, sans-serif">If you try to run it, it fails with the following message:<br>
<br></font></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="'courier new', monospace">escript: exception error: undefined function erl_eval:add1/1</font></blockquote><div><font face="verdana, sans-serif"><br></font></div>
<div><font face="verdana, sans-serif">If you try this one instead...<br><br></font></div><div>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="'courier new', monospace">#!/usr/bin/env escript</font> </blockquote><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">add1(</span><span class="s1" style="font-family: 'courier new', monospace; ">X</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">) -></span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> </span><span class="s1" style="font-family: 'courier new', monospace; ">X</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> </span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">+</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> </span><span class="s4" style="font-family: 'courier new', monospace; ">1</span><span class="s5" style="font-family: 'courier new', monospace; ">.</span><font face="'courier new', monospace"><br>
</font><font face="'courier new', monospace">main(<span>_Args</span>) -> lists:map(<span>fun</span> <span>?MODULE</span>:add1/<span>1</span>, lists:seq(<span>1</span>,<span>10</span>))<span>.<br>
</span></font></blockquote></div><div><font face="verdana, sans-serif"><br></font></div><div><font face="verdana, sans-serif">Then you get...<br><br></font></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="'courier new', monospace">priv/test:3: Warning: function add1/1 is unused<br>escript: exception error: undefined function test__escript__1322__149559__518984:add1/1<br> in function lists:map/2<br>
in call from erl_eval:local_func/5<br> in call from escript:interpret/4<br> in call from escript:start/1<br> in call from init:start_it/1<br> in call from init:start_em/1</font></blockquote></div><div><font face="verdana, sans-serif"><br>
</font></div><div><font face="verdana, sans-serif">It's not too complicated to work around, but I thought I should share it.</font></div><div><font face="verdana, sans-serif">Cheers</font></div>
</blockquote><div><div style="text-align:right"><font face="verdana, sans-serif"><b><i><a href="http://google.com/profiles/greenmellon" target="_blank">Fernando Benavides</a></i></b></font></div><br>
</div>