<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Multimethod in Clojure: Should I call it first class Pattern Matching? or Pattern Matching in disguise?</title>
	<atom:link href="http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/feed/" rel="self" type="application/rss+xml" />
	<link>http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/</link>
	<description>Sadek Drobi</description>
	<lastBuildDate>Mon, 02 Nov 2009 05:56:20 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Werner Schuster (murphee)</title>
		<link>http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/comment-page-1/#comment-15481</link>
		<dc:creator>Werner Schuster (murphee)</dc:creator>
		<pubDate>Fri, 29 May 2009 09:39:38 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/#comment-15481</guid>
		<description>Pattern Matching: My experience with pattern matching comes mostly from working with Mathematica, and I&#039;m not sure I see the closed property there. You can define new &#039;methods&#039; (in the multi-method sense) anywhere, anytime. 
The evaluation order is based on definition order - BUT it can be changed by reordering the definitions (http://reference.wolfram.com/mathematica/ref/DownValues.html). 

I have been thinking about doing Mathematica-style pattern matching with Clojure; I think it&#039;s possible using the method reflection calls, which allow to get all the dispatch values + methods for a multi-method name. With that, it&#039;d be possible to interpret the dispatch values as pattern definitions and to generate an optimized pattern matcher for a set of multi-methods. Mind you - I&#039;m not sure how to get the openness property back, though. Ie. if a pattern matcher is generated for a set of multi-methods, and then someone adds another definition for a multi-method -&gt; then the pattern matcher dispatch function would be outdated. The only solution would be to have a dispatch function that always gets the definitions of all the multi-methods, and does the pattern matching with that - but that&#039;d preclude the construction of an optimized, specialized pattern matcher function. 

As for where multi-dispatch fits - as I argue here:
http://www.jroller.com/murphee/entry/hell_hath_no_fury_like
it&#039;s a very general type of (runtime) polymorphism - so general that it subsumes many specialized features of OOP languages (static overloading, virtual methods, etc  As we see with Clojure&#039;s dispatch functions, they can also be made to implement class hierarchies).</description>
		<content:encoded><![CDATA[<p>Pattern Matching: My experience with pattern matching comes mostly from working with Mathematica, and I&#8217;m not sure I see the closed property there. You can define new &#8216;methods&#8217; (in the multi-method sense) anywhere, anytime.<br />
The evaluation order is based on definition order &#8211; BUT it can be changed by reordering the definitions (<a href="http://reference.wolfram.com/mathematica/ref/DownValues.html)" rel="nofollow">http://reference.wolfram.com/mathematica/ref/DownValues.html)</a>. </p>
<p>I have been thinking about doing Mathematica-style pattern matching with Clojure; I think it&#8217;s possible using the method reflection calls, which allow to get all the dispatch values + methods for a multi-method name. With that, it&#8217;d be possible to interpret the dispatch values as pattern definitions and to generate an optimized pattern matcher for a set of multi-methods. Mind you &#8211; I&#8217;m not sure how to get the openness property back, though. Ie. if a pattern matcher is generated for a set of multi-methods, and then someone adds another definition for a multi-method -&gt; then the pattern matcher dispatch function would be outdated. The only solution would be to have a dispatch function that always gets the definitions of all the multi-methods, and does the pattern matching with that &#8211; but that&#8217;d preclude the construction of an optimized, specialized pattern matcher function. </p>
<p>As for where multi-dispatch fits &#8211; as I argue here:<br />
<a href="http://www.jroller.com/murphee/entry/hell_hath_no_fury_like" rel="nofollow">http://www.jroller.com/murphee/entry/hell_hath_no_fury_like</a><br />
it&#8217;s a very general type of (runtime) polymorphism &#8211; so general that it subsumes many specialized features of OOP languages (static overloading, virtual methods, etc  As we see with Clojure&#8217;s dispatch functions, they can also be made to implement class hierarchies).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: spooky</title>
		<link>http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/comment-page-1/#comment-15459</link>
		<dc:creator>spooky</dc:creator>
		<pubDate>Thu, 28 May 2009 23:00:39 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/#comment-15459</guid>
		<description>Multimethods are normal in common lisp (CLOS) and several other multiple-dispatch languages.  I have no idea how clojure&#039;s might differ, but they&#039;re not some new thing in the grand scheme of things.

http://en.wikipedia.org/wiki/Multiple_dispatch</description>
		<content:encoded><![CDATA[<p>Multimethods are normal in common lisp (CLOS) and several other multiple-dispatch languages.  I have no idea how clojure&#8217;s might differ, but they&#8217;re not some new thing in the grand scheme of things.</p>
<p><a href="http://en.wikipedia.org/wiki/Multiple_dispatch" rel="nofollow">http://en.wikipedia.org/wiki/Multiple_dispatch</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sadache</title>
		<link>http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/comment-page-1/#comment-15438</link>
		<dc:creator>Sadache</dc:creator>
		<pubDate>Thu, 28 May 2009 10:56:37 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/#comment-15438</guid>
		<description>Thank you Rich for the explanation. It reminds me now of a frequent question in the Haskell community about whether Type Classes overlap with GAT. It gets always back to the interesting property of open/close. I just can&#039;t imagine enough the possibilities the mechanism offers in the same time as complexity it adds. I guess multimethod alone calls for a new paradigm of programming yet to be discovered.</description>
		<content:encoded><![CDATA[<p>Thank you Rich for the explanation. It reminds me now of a frequent question in the Haskell community about whether Type Classes overlap with GAT. It gets always back to the interesting property of open/close. I just can&#8217;t imagine enough the possibilities the mechanism offers in the same time as complexity it adds. I guess multimethod alone calls for a new paradigm of programming yet to be discovered.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich Hickey</title>
		<link>http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/comment-page-1/#comment-15412</link>
		<dc:creator>Rich Hickey</dc:creator>
		<pubDate>Wed, 27 May 2009 21:59:46 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-should-i-call-it-first-class-pattern-matching-or-pattern-matching-in-disguise/#comment-15412</guid>
		<description>Multimethods differ from pattern matching in a number of ways. Two that matter (to me) are:

Pattern matching is usually &#039;closed&#039;, in the sense that all possibilities must be enumerated in a single scope.

Pattern matches are usually declaration order dependent.

Multimethods, OTOH, are an open set. You can define a new method any time, anywhere - they need not be lexically co-located. Multimethod operation is independent of definition order. They are very dynamic, and thus a good fit for Clojure.

There are other differences, of course, e.g. pattern matching usually has sugar for structural and type matches, and often exhaustiveness checking. I&#039;m still waiting for someone to contribute a pattern-matching macro for Clojure, as I don&#039;t think one makes the other redundant.</description>
		<content:encoded><![CDATA[<p>Multimethods differ from pattern matching in a number of ways. Two that matter (to me) are:</p>
<p>Pattern matching is usually &#8216;closed&#8217;, in the sense that all possibilities must be enumerated in a single scope.</p>
<p>Pattern matches are usually declaration order dependent.</p>
<p>Multimethods, OTOH, are an open set. You can define a new method any time, anywhere &#8211; they need not be lexically co-located. Multimethod operation is independent of definition order. They are very dynamic, and thus a good fit for Clojure.</p>
<p>There are other differences, of course, e.g. pattern matching usually has sugar for structural and type matches, and often exhaustiveness checking. I&#8217;m still waiting for someone to contribute a pattern-matching macro for Clojure, as I don&#8217;t think one makes the other redundant.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
