<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Erlang For The Practical Man</title>
	<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Fri, 05 Sep 2008 19:21:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>

	<item>
		<title>By: dizzyd</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1595</link>
		<author>dizzyd</author>
		<pubDate>Wed, 09 May 2007 14:18:41 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1595</guid>
					<description>Generally speaking, there's no need to do all those list appends (in the rss_wrap_item function). A simpler and more efficient approach would be to simply return a list of strings and allow the serialization routine to flatten in (which I believe happens in the VM). So rss_wrap_item becomes:

rss_wrap_item({message, Date, From, Subject, Content}) -&#62;
   [ "&#60;item&#62;",  "&#60;title&#62;", Subject, "&#60;/title&#62;",
      "&#60;description&#62;",  “From: “,  escape_from(From),
        Content,  "&#60;/description&#62;", "&#60;pubDate&#62;", Date, 
       "&#60;/pubDate&#62;", "&#60;/item&#62;" ].

This allows you to avoid the creation of a whole mess of lists.</description>
		<content:encoded><![CDATA[<p>Generally speaking, there&#8217;s no need to do all those list appends (in the rss_wrap_item function). A simpler and more efficient approach would be to simply return a list of strings and allow the serialization routine to flatten in (which I believe happens in the VM). So rss_wrap_item becomes:</p>
<p>rss_wrap_item({message, Date, From, Subject, Content}) -&gt;<br />
   [ &#8220;&lt;item&gt;&#8221;,  &#8220;&lt;title&gt;&#8221;, Subject, &#8220;&lt;/title&gt;&#8221;,<br />
      &#8220;&lt;description&gt;&#8221;,  “From: “,  escape_from(From),<br />
        Content,  &#8220;&lt;/description&gt;&#8221;, &#8220;&lt;pubDate&gt;&#8221;, Date,<br />
       &#8220;&lt;/pubDate&gt;&#8221;, &#8220;&lt;/item&gt;&#8221; ].</p>
<p>This allows you to avoid the creation of a whole mess of lists.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mazen</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1597</link>
		<author>Mazen</author>
		<pubDate>Wed, 09 May 2007 14:23:22 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1597</guid>
					<description>Hiya, Nice to see another page showing Erlang :) You are more then welcome to our portal where you can discuss more Erlang. And if you haven't already, subscribe to the mailing list :)

Good job :) and have a nice day

/Mazen</description>
		<content:encoded><![CDATA[<p>Hiya, Nice to see another page showing Erlang :) You are more then welcome to our portal where you can discuss more Erlang. And if you haven&#8217;t already, subscribe to the mailing list :)</p>
<p>Good job :) and have a nice day</p>
<p>/Mazen</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: stiff</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1598</link>
		<author>stiff</author>
		<pubDate>Wed, 09 May 2007 14:51:18 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1598</guid>
					<description>dizzyd: I wanted to keep it as simple as possible for people who never programmed Erlang before and doing things like that isn't too natural in an introductory example. Thanks for the tip through, I must admit I didn't know about this.

Mazen: I'm glad you enjoyed the article. I know about trapexit and I like it :)

Some people at reddit noticed that the element function is used instead of pattern matching. I did it for the sake of learning - I needed to limit the amount of new concepts introduced in one example. I edited the article a tiny bit to clarify this.</description>
		<content:encoded><![CDATA[<p>dizzyd: I wanted to keep it as simple as possible for people who never programmed Erlang before and doing things like that isn&#8217;t too natural in an introductory example. Thanks for the tip through, I must admit I didn&#8217;t know about this.</p>
<p>Mazen: I&#8217;m glad you enjoyed the article. I know about trapexit and I like it :)</p>
<p>Some people at reddit noticed that the element function is used instead of pattern matching. I did it for the sake of learning - I needed to limit the amount of new concepts introduced in one example. I edited the article a tiny bit to clarify this.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: lispnik</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1599</link>
		<author>lispnik</author>
		<pubDate>Wed, 09 May 2007 15:23:03 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1599</guid>
					<description>Did you consider using epop http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/epop/ a POP3 client library and server?</description>
		<content:encoded><![CDATA[<p>Did you consider using epop <a href="http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/epop/" rel="nofollow">http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/epop/</a> a POP3 client library and server?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: stiff</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1600</link>
		<author>stiff</author>
		<pubDate>Wed, 09 May 2007 15:55:06 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1600</guid>
					<description>lispnik: I saw epop - if I was writing this application for real I would probably use it. But this example was created only for the tutorial and I wanted to stick with what Erlang has by default.  All things aside, implementing a client for a popular protocol on your own is a fun thing to do :)</description>
		<content:encoded><![CDATA[<p>lispnik: I saw epop - if I was writing this application for real I would probably use it. But this example was created only for the tutorial and I wanted to stick with what Erlang has by default.  All things aside, implementing a client for a popular protocol on your own is a fun thing to do :)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: How to build a POP3 to RSS gateway in Erlang &#124; the pix zone</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1601</link>
		<author>How to build a POP3 to RSS gateway in Erlang &#124; the pix zone</author>
		<pubDate>Wed, 09 May 2007 17:37:06 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1601</guid>
					<description>[...] Rzeszótko wrote this great article where he builds a POP3 to RSS gateway in Erlang. Very nice stuff and well written article on the topic. He&#8217;s also running for the Erlang [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Rzeszótko wrote this great article where he builds a POP3 to RSS gateway in Erlang. Very nice stuff and well written article on the topic. He&#8217;s also running for the Erlang [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: dizzyd</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1602</link>
		<author>dizzyd</author>
		<pubDate>Wed, 09 May 2007 21:24:17 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1602</guid>
					<description>stiff: Yeah, it makes sense to keep the tutorial simple. I just wanted to point that out as it can be _massively_ slow (something I learned the hard way). 

Nice work though -- erlang tutorial are always a good thing. :)</description>
		<content:encoded><![CDATA[<p>stiff: Yeah, it makes sense to keep the tutorial simple. I just wanted to point that out as it can be _massively_ slow (something I learned the hard way). </p>
<p>Nice work though &#8212; erlang tutorial are always a good thing. :)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: aidan</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1604</link>
		<author>aidan</author>
		<pubDate>Wed, 09 May 2007 23:36:22 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1604</guid>
					<description>wow. excellent tutorial, really nice introduction - easy to understand whilst still providing a great example of a real world application. look forward to reading more here in the future.</description>
		<content:encoded><![CDATA[<p>wow. excellent tutorial, really nice introduction - easy to understand whilst still providing a great example of a real world application. look forward to reading more here in the future.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: links for 2007-05-10 &#171; Bloggitation</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1606</link>
		<author>links for 2007-05-10 &#171; Bloggitation</author>
		<pubDate>Thu, 10 May 2007 00:19:59 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1606</guid>
					<description>[...] Stifflog - Erlang For The Practical Man (tags: erlang programming web blog) [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Stifflog - Erlang For The Practical Man (tags: erlang programming web blog) [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: petekaz</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1607</link>
		<author>petekaz</author>
		<pubDate>Thu, 10 May 2007 01:37:20 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1607</guid>
					<description>Although I realize this tutorial is for beginners, there is a common mistake present in the networking code. Your call to gen_tcp:recv assumes that the HTTP GET request arrives in a single TCP segment, which almost always happens in this scenario; however, it is bad programming practice to assume so.  If the TCP MSS is small, it is possible that one TCP segment would arrive with a portion of the GET request, "GE".  Then a second segment might arrive containing the rest of it, "T /".  Although your code will catch this scenario, I suspect this was not the intention in this scenario. With a line based protocol such as HTTP, you should investigate the {packet, line} option instead.

With all of the recent hype around Erlang (which is a good thing IMHO), I just want to make sure folks understand some of the ramifications of network programming.</description>
		<content:encoded><![CDATA[<p>Although I realize this tutorial is for beginners, there is a common mistake present in the networking code. Your call to gen_tcp:recv assumes that the HTTP GET request arrives in a single TCP segment, which almost always happens in this scenario; however, it is bad programming practice to assume so.  If the TCP MSS is small, it is possible that one TCP segment would arrive with a portion of the GET request, &#8220;GE&#8221;.  Then a second segment might arrive containing the rest of it, &#8220;T /&#8221;.  Although your code will catch this scenario, I suspect this was not the intention in this scenario. With a line based protocol such as HTTP, you should investigate the {packet, line} option instead.</p>
<p>With all of the recent hype around Erlang (which is a good thing IMHO), I just want to make sure folks understand some of the ramifications of network programming.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Amr</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1608</link>
		<author>Amr</author>
		<pubDate>Thu, 10 May 2007 02:07:20 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1608</guid>
					<description>Are you able to provide a "print" version of your excellent article? thanks much!</description>
		<content:encoded><![CDATA[<p>Are you able to provide a &#8220;print&#8221; version of your excellent article? thanks much!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: stiff</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1609</link>
		<author>stiff</author>
		<pubDate>Thu, 10 May 2007 04:03:26 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1609</guid>
					<description>Petekaz: I know what you mean, we even talked about this in the POP3 part:

"Going back to pop3, the general pattern of communication will be not too surprisingly Request -&gt; Response, so maybe we can capture a higher level abstraction… Actually, we also don’t have a guarantee that the response will come in one portion (hence one ssl:recv), so we need to pull data out of the socket until we reach a CR/LF at the end"

In the http server, through, I didn't want to work through the same thing again. Since the data pulled out of the socket is accumulated, a "GET /" is caught even if it arrives in more than one packet. But as with the other comments, this is a great place to point out or emphasize things like that. Thanks!

Amr: I will try to provide it soon.</description>
		<content:encoded><![CDATA[<p>Petekaz: I know what you mean, we even talked about this in the POP3 part:</p>
<p>&#8220;Going back to pop3, the general pattern of communication will be not too surprisingly Request -> Response, so maybe we can capture a higher level abstraction… Actually, we also don’t have a guarantee that the response will come in one portion (hence one ssl:recv), so we need to pull data out of the socket until we reach a CR/LF at the end&#8221;</p>
<p>In the http server, through, I didn&#8217;t want to work through the same thing again. Since the data pulled out of the socket is accumulated, a &#8220;GET /&#8221; is caught even if it arrives in more than one packet. But as with the other comments, this is a great place to point out or emphasize things like that. Thanks!</p>
<p>Amr: I will try to provide it soon.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: stiff</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1610</link>
		<author>stiff</author>
		<pubDate>Thu, 10 May 2007 05:40:22 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1610</guid>
					<description>[ I uploaded two PDFs for printing or easier reading, links are at the beginning of the article ]</description>
		<content:encoded><![CDATA[<p>[ I uploaded two PDFs for printing or easier reading, links are at the beginning of the article ]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Zeno Davatz</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1612</link>
		<author>Zeno Davatz</author>
		<pubDate>Thu, 10 May 2007 07:34:07 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1612</guid>
					<description>Thank you for your post. I have been looking for this quite some time. 

So how do I get this up and running so that I can subscribe to my Gmail-RSS in my Google-Reader?

Thank you!

Zeno</description>
		<content:encoded><![CDATA[<p>Thank you for your post. I have been looking for this quite some time. </p>
<p>So how do I get this up and running so that I can subscribe to my Gmail-RSS in my Google-Reader?</p>
<p>Thank you!</p>
<p>Zeno</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: stiff</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1613</link>
		<author>stiff</author>
		<pubDate>Thu, 10 May 2007 08:07:54 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1613</guid>
					<description>Zeno: Basically it goes like that: you replace the dummy data in the code with your gmail login credentials. Than you start the erlang shell, and compile everything:

c(message).
c(pop3).
c(http).
c(rss_wrap).
c(gmailrss).

Now you can run the thing:

gmailrss:main().

As Google Reader is a web application, so I believe it won't work with "http://localhost/" as the feed address - you need to supply it with your IP or domain name, accessible from the web. The problem with this is that everybody will be able to read the feed, and thus the contents of your email account, I don't know if there is a way to do some sort of authentication. With a local feed reader, you can just run it on 127.0.0.1 (by changing the gen_tcp:listen in the http module a tiny bit) and don't care about that.

Anyway, if this was meant for production use, I would change a few things and add a bit more error handling...</description>
		<content:encoded><![CDATA[<p>Zeno: Basically it goes like that: you replace the dummy data in the code with your gmail login credentials. Than you start the erlang shell, and compile everything:</p>
<p>c(message).<br />
c(pop3).<br />
c(http).<br />
c(rss_wrap).<br />
c(gmailrss).</p>
<p>Now you can run the thing:</p>
<p>gmailrss:main().</p>
<p>As Google Reader is a web application, so I believe it won&#8217;t work with &#8220;http://localhost/&#8221; as the feed address - you need to supply it with your IP or domain name, accessible from the web. The problem with this is that everybody will be able to read the feed, and thus the contents of your email account, I don&#8217;t know if there is a way to do some sort of authentication. With a local feed reader, you can just run it on 127.0.0.1 (by changing the gen_tcp:listen in the http module a tiny bit) and don&#8217;t care about that.</p>
<p>Anyway, if this was meant for production use, I would change a few things and add a bit more error handling&#8230;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Amr</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1616</link>
		<author>Amr</author>
		<pubDate>Thu, 10 May 2007 16:47:54 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1616</guid>
					<description>Thanks so much for taking the time to make the PDF's that is awesome! Now I can read it again on my ride home :)</description>
		<content:encoded><![CDATA[<p>Thanks so much for taking the time to make the PDF&#8217;s that is awesome! Now I can read it again on my ride home :)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Think in Read &#187; links for 2007-05-11</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1623</link>
		<author>Think in Read &#187; links for 2007-05-11</author>
		<pubDate>Fri, 11 May 2007 01:22:35 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1623</guid>
					<description>[...] Stifflog - Erlang For The Practical Man (tags: erlang tutorial)    归类于： daily del.licio.us &#8212; rainhanket @ 9:22 am [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Stifflog - Erlang For The Practical Man (tags: erlang tutorial)    归类于： daily del.licio.us &#8212; rainhanket @ 9:22 am [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: iceman</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1651</link>
		<author>iceman</author>
		<pubDate>Wed, 16 May 2007 03:09:06 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1651</guid>
					<description>Nice article - I found it very helpful as I am starting to look into Erlang.</description>
		<content:encoded><![CDATA[<p>Nice article - I found it very helpful as I am starting to look into Erlang.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: The (Unofficial) Erlang Blog &#187; Blog Archive &#187; Article: Erlang for the Practical Man</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1661</link>
		<author>The (Unofficial) Erlang Blog &#187; Blog Archive &#187; Article: Erlang for the Practical Man</author>
		<pubDate>Fri, 18 May 2007 00:48:19 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1661</guid>
					<description>[...] submission to the Erlang blogging contest, Jarosław Rzeszótko has written a great practical introduction to the language. In it, he shows readers how to syndicate a POP3 mailbox as an RSS feed using your very own [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] submission to the Erlang blogging contest, Jarosław Rzeszótko has written a great practical introduction to the language. In it, he shows readers how to syndicate a POP3 mailbox as an RSS feed using your very own [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: TomP</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-2127</link>
		<author>TomP</author>
		<pubDate>Mon, 02 Jul 2007 01:18:15 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-2127</guid>
					<description>Thanks very much for this stimulating article.  It's at a very appropriate level for those of us who've just come from 'Programming Erlang' and are looking for examples that tie everything together.  

That said, I have a couple of comments:

1) I want to second dizzyd's suggestion that the string concatenations are unnecessary and (actually) bad Erlang style.  Simply creating lists of strings and flattening them when necessary is better style.

2) In the pop3 module, you can make the connection to the POP3 server line-oriented by setting the property '{packet, line}' in the gen_tcp:connect() call.  This simplifies the code that processes responses from the POP3 server, because you don't need to keep looking for "\r\n" sequences.

3) The message module is adequate for what you're using it for here, but mail headers can't be parsed like this in general, because header fields can span multiple lines.  It takes very little additional code to create a robust message parser that handles multiline header fields correctly.

4) It would be useful and instructive to add the code necessary to shut the htp server down cleanly.  (I think that with your example, you actually need to shut down the entire Erlang node to terminate the http server.)  There are probably different ways of doing this, but added a 'stop -&#62; exit(stopped);' clause to the 'receive' statement for the control_server() and added a line to the http:initialize() function to link it to the control server process.

I think it would be nice to have a followup article in which issues like these were addressed and the entire project recast as an OTP application.  But, again, thank you for this article; it would definitely get my vote as the winner of Dave Thomas' Erlang blogging challange.</description>
		<content:encoded><![CDATA[<p>Thanks very much for this stimulating article.  It&#8217;s at a very appropriate level for those of us who&#8217;ve just come from &#8216;Programming Erlang&#8217; and are looking for examples that tie everything together.  </p>
<p>That said, I have a couple of comments:</p>
<p>1) I want to second dizzyd&#8217;s suggestion that the string concatenations are unnecessary and (actually) bad Erlang style.  Simply creating lists of strings and flattening them when necessary is better style.</p>
<p>2) In the pop3 module, you can make the connection to the POP3 server line-oriented by setting the property &#8216;{packet, line}&#8217; in the gen_tcp:connect() call.  This simplifies the code that processes responses from the POP3 server, because you don&#8217;t need to keep looking for &#8220;\r\n&#8221; sequences.</p>
<p>3) The message module is adequate for what you&#8217;re using it for here, but mail headers can&#8217;t be parsed like this in general, because header fields can span multiple lines.  It takes very little additional code to create a robust message parser that handles multiline header fields correctly.</p>
<p>4) It would be useful and instructive to add the code necessary to shut the htp server down cleanly.  (I think that with your example, you actually need to shut down the entire Erlang node to terminate the http server.)  There are probably different ways of doing this, but added a &#8217;stop -&gt; exit(stopped);&#8217; clause to the &#8216;receive&#8217; statement for the control_server() and added a line to the http:initialize() function to link it to the control server process.</p>
<p>I think it would be nice to have a followup article in which issues like these were addressed and the entire project recast as an OTP application.  But, again, thank you for this article; it would definitely get my vote as the winner of Dave Thomas&#8217; Erlang blogging challange.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Me</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-2240</link>
		<author>Me</author>
		<pubDate>Sun, 22 Jul 2007 11:44:27 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-2240</guid>
					<description>Hi, is there a bug in the following code?

control_server(Response) -&#62;
    receive
        {set, response, NewResponse} -&#62;
            control_server(NewResponse);
        {get, response, Pid} -&#62;
            Pid ! {response, Response};
        _ -&#62;
            control_server(Response)
    end.

Shouldn't the control_server loop after a "get"? Something like this:

control_server(Response) -&#62;
    receive
        {set, response, NewResponse} -&#62;
            control_server(NewResponse);
        {get, response, Pid} -&#62;
            Pid ! {response, Response},
            control_server(Response);
        _ -&#62;
            control_server(Response)
    end.

Great tutorial on Erlang (the first that I read)!</description>
		<content:encoded><![CDATA[<p>Hi, is there a bug in the following code?</p>
<p>control_server(Response) -&gt;<br />
    receive<br />
        {set, response, NewResponse} -&gt;<br />
            control_server(NewResponse);<br />
        {get, response, Pid} -&gt;<br />
            Pid ! {response, Response};<br />
        _ -&gt;<br />
            control_server(Response)<br />
    end.</p>
<p>Shouldn&#8217;t the control_server loop after a &#8220;get&#8221;? Something like this:</p>
<p>control_server(Response) -&gt;<br />
    receive<br />
        {set, response, NewResponse} -&gt;<br />
            control_server(NewResponse);<br />
        {get, response, Pid} -&gt;<br />
            Pid ! {response, Response},<br />
            control_server(Response);<br />
        _ -&gt;<br />
            control_server(Response)<br />
    end.</p>
<p>Great tutorial on Erlang (the first that I read)!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: mera</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-4953</link>
		<author>mera</author>
		<pubDate>Mon, 26 May 2008 14:01:12 +0000</pubDate>
		<guid>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-4953</guid>
					<description>Error:
    gen_tcp:close(Socket).
process_request(Socket, _) -&#62;
    0.
Shuld be:
    gen_tcp:close(Socket);
process_request(Socket, _) -&#62;
    0.
Nice tut.</description>
		<content:encoded><![CDATA[<p>Error:<br />
    gen_tcp:close(Socket).<br />
process_request(Socket, _) -&gt;<br />
    0.<br />
Shuld be:<br />
    gen_tcp:close(Socket);<br />
process_request(Socket, _) -&gt;<br />
    0.<br />
Nice tut.</p>
]]></content:encoded>
				</item>
</channel>
</rss>
