<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
span.EmailStyle19
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Good morning,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m learning Erlang using the <i>Programming Erlang</i> (2d ed) text from Pragmatic Bookshelf. Chapter two, “A Whirlwind Tour of Erlang” includes a file server sample that’s failing to work as the book suggests, and I’m afraid I’m not getting anywhere figuring it out. First, here’s the server code:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>-module</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>(afile_server).<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>-export</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>([start/1]).<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>start(Dir) -> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#2996B5'>spawn</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>(afile_server, loop, [Dir]).<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>loop(Dir) -><o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>receive</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> {Client, list_dir} -><o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Client ! {</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2996B5'>self</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>(), file:list_dir(Dir)};<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> {Client, {get_file, File}} -><o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Full = filename:join(Dir, File),<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Client ! {</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2996B5'>self</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>(), file:read_file(Full)}<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>end</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>,<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in;background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> loop(Dir).<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal>That compiles (albeit with a warning saying “Warning: function loop/1 is unused”) but when I try to execute it from within the shell I get an error. For sake of reference the shell commands I’m issuing are:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-left:.5in'>Eshell V5.10.1 (abort with ^G)<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>1> c(afile_server).<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>afile_server.erl:7: Warning: function loop/1 is unused<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>{ok,afile_server}<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>2> FileServer = afile_server:start(".").<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'><0.39.0><o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>3><o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>=ERROR REPORT==== 10-Apr-2013::10:31:17 ===<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>Error in process <0.39.0> with exit value: {undef,[{afile_server,loop,["."],[]}]}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Can anyone suggest what might be wrong? I’m running under Windows 7 Professional x64 for sake of reference. Thanks in advance!<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John<o:p></o:p></p></div></body></html>