<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bubble Foundry &#187; methods</title>
	<atom:link href="http://www.bubblefoundry.com/blog/tag/methods/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bubblefoundry.com</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 18:23:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://www.bubblefoundry.com/?pushpress=hub'/>
		<item>
		<title>My latest Scala-inspired Javascript library: pf.js</title>
		<link>http://www.bubblefoundry.com/blog/2010/02/my-latest-scala-inspired-javascript-library-pf-js/</link>
		<comments>http://www.bubblefoundry.com/blog/2010/02/my-latest-scala-inspired-javascript-library-pf-js/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 04:26:46 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[partial functions]]></category>
		<category><![CDATA[pf.js]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://www.bubblefoundry.com/?p=313</guid>
		<description><![CDATA[What is a function? While many use the words &#8216;method&#8217; and &#8216;function&#8217; interchangeably, more mathematically-inclined programmers make a distinction between functions and methods based on between you are guaranteed a return value. Scala is one programming language that makes a distinction between functions and methods (though it&#8217;s actually pretty easy to jump between the two). [...]]]></description>
			<content:encoded><![CDATA[<p>What is a function? While many use the words &#8216;method&#8217; and &#8216;function&#8217; interchangeably, more mathematically-inclined programmers make a distinction between <a href="http://en.wikipedia.org/wiki/Function_(mathematics)">functions</a> and <a href="http://en.wikipedia.org/wiki/Function_(computer_science)">methods</a> based on between you are guaranteed a return value. Scala is one programming language that makes a <a href="http://jim-mcbeath.blogspot.com/2009/05/scala-functions-vs-methods.html">distinction between functions and methods</a> (though it&#8217;s actually pretty easy to jump between the two). Great, just like plenty of other languages, nothing special here. Javascript functions are funny beasts. On one hand, they seem to be simple subroutines which can be passed arguments and can <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)">enclose</a> variables – pretty standard methods in other words. However, regardless of whether you include <code>return</code> statements in a function, <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference:Functions#General">something is actually returned</a>, <code>undefined</code> being returned if you hadn&#8217;t specified a return value. Hmm, so they&#8217;re kind of like mathematical methods except there&#8217;s no way to know without looking at a function&#8217;s source code whether the author failed to return a value for the input you gave it or actually did return something, the <code>undefined</code> object.</p>
<p>However, Scala also provides a middle ground with <a href="http://suereth.blogspot.com/2008/11/using-partial-functions-and-pattern.html">PartialFunctions</a>. PartialFunctions are cool because they are only defined for specific inputs and you can check this. In addition, because they are defined for specific inputs, you can combine several PartialFunctions to create a new PartialFunction which is defined for the union of all the original PartialFunctions&#8217; inputs. Wouldn&#8217;t it be cool if Javascript did that too? Well, now it can with <a href="http://github.com/pr1001/pf.js">pf.js</a>. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubblefoundry.com/blog/2010/02/my-latest-scala-inspired-javascript-library-pf-js/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

