<?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: On static and dynamic typing, and corn tortillas</title>
	<atom:link href="http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/feed/" rel="self" type="application/rss+xml" />
	<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/</link>
	<description>programming, usability, and interaction design</description>
	<lastBuildDate>Wed, 11 Aug 2010 20:40:29 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Greg Buchholz</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-23</link>
		<dc:creator>Greg Buchholz</dc:creator>
		<pubDate>Thu, 11 Jan 2007 23:13:14 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-23</guid>
		<description>&lt;p&gt;You get a compiler error.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You get a compiler error.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-21</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Thu, 11 Jan 2007 21:23:14 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-21</guid>
		<description>&lt;p&gt;Ok, but in those examples, what happens if you instanitate a list&lt;myclass&gt;, where MyClass doesn&#039;t implement operator+?&lt;/myclass&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Ok, but in those examples, what happens if you instanitate a list<myclass>, where MyClass doesn&#8217;t implement operator+?</myclass></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Buchholz</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-20</link>
		<dc:creator>Greg Buchholz</dc:creator>
		<pubDate>Thu, 11 Jan 2007 16:04:41 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-20</guid>
		<description>&lt;p&gt;Here&#039;s a better operator+ for that example (now with angle brackets)...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;pre&gt;
template&lt;class T&gt; T operator+(T a, T b)
{
   T out;
   transform(a.begin(),a.end(),b.begin(),back_inserter(out),
             p&lt;typename T::value_type&gt;);
   return out;
}

&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a better operator+ for that example (now with angle brackets)&#8230;</p>

<p><code><pre>
template&lt;class T&gt; T operator+(T a, T b)
{
   T out;
   transform(a.begin(),a.end(),b.begin(),back_inserter(out),
             p&lt;typename T::value_type&gt;);
   return out;
}

</pre></code></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Buchholz</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-19</link>
		<dc:creator>Greg Buchholz</dc:creator>
		<pubDate>Thu, 11 Jan 2007 16:03:37 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-19</guid>
		<description>&lt;p&gt;Here&#039;s a better operator+ for that example...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;pre&gt;
template T operator+(T a, T b)
{
   T out;
   transform(a.begin(),a.end(),b.begin(),back_inserter(out),
             p);
   return out;
}

&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a better operator+ for that example&#8230;</p>

<p><code><pre>
template T operator+(T a, T b)
{
   T out;
   transform(a.begin(),a.end(),b.begin(),back_inserter(out),
             p);
   return out;
}

</pre></code></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Buchholz</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-18</link>
		<dc:creator>Greg Buchholz</dc:creator>
		<pubDate>Thu, 11 Jan 2007 03:23:01 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-18</guid>
		<description>&lt;p&gt;Here&#039;s the similar thing in C++ which will work with lists of doubles, lists of lists of ints, etc...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;b&gt;#include&lt;/b&gt;&lt;iostream&gt;
&lt;b&gt;#include&lt;/b&gt;&lt;list&gt;
&lt;b&gt;#include&lt;/b&gt;&lt;iterator&gt;

&lt;b&gt;using&lt;/b&gt; &lt;b&gt;namespace&lt;/b&gt; std;

&lt;b&gt;template&lt;/b&gt;&lt;&lt;b&gt;class&lt;/b&gt; T&gt; T &lt;b&gt;p&lt;/b&gt;(T a, T b){ &lt;b&gt;return&lt;/b&gt; a+b; }
&lt;b&gt;template&lt;/b&gt;&lt;&lt;b&gt;class&lt;/b&gt; T&gt; list&lt;T&gt; &lt;b&gt;operator&lt;/b&gt;+(list&lt;T&gt; a, list&lt;T&gt; b)
{
   list&lt;T&gt; out;
   &lt;b&gt;transform&lt;/b&gt;(a.&lt;b&gt;begin&lt;/b&gt;(),a.&lt;b&gt;end&lt;/b&gt;(),b.&lt;b&gt;begin&lt;/b&gt;(),&lt;b&gt;back_inserter&lt;/b&gt;(out),p&lt;T&gt;);
   &lt;b&gt;return&lt;/b&gt; out;
}

int &lt;b&gt;main&lt;/b&gt;(int argc, char* argv[])
{
    double x[] = { 1.0, 2.0, 3.0};
    double y[] = {10.0,11.0,12.0};
    list&lt;double&gt; &lt;b&gt;a&lt;/b&gt;(x,x+&lt;b&gt;sizeof&lt;/b&gt;(x)/&lt;b&gt;sizeof&lt;/b&gt;(double));
    list&lt;double&gt; &lt;b&gt;b&lt;/b&gt;(y,y+&lt;b&gt;sizeof&lt;/b&gt;(y)/&lt;b&gt;sizeof&lt;/b&gt;(double));
    list&lt;double&gt; c;

    c = a+b;

    &lt;b&gt;copy&lt;/b&gt;(c.&lt;b&gt;begin&lt;/b&gt;(),c.&lt;b&gt;end&lt;/b&gt;(),ostream_iterator&lt;double&gt;(cout, &quot;\n&quot;));

    &lt;b&gt;return&lt;/b&gt; 0;
}
&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Here&#8217;s the similar thing in C++ which will work with lists of doubles, lists of lists of ints, etc&#8230;</p>

<p><code></code></p>

<pre><b>#include</b>&lt;iostream&gt;
<b>#include</b>&lt;list&gt;
<b>#include</b>&lt;iterator&gt;

<b>using</b> <b>namespace</b> std;

<b>template</b>&lt;<b>class</b> T&gt; T <b>p</b>(T a, T b){ <b>return</b> a+b; }
<b>template</b>&lt;<b>class</b> T&gt; list&lt;T&gt; <b>operator</b>+(list&lt;T&gt; a, list&lt;T&gt; b)
{
   list&lt;T&gt; out;
   <b>transform</b>(a.<b>begin</b>(),a.<b>end</b>(),b.<b>begin</b>(),<b>back_inserter</b>(out),p&lt;T&gt;);
   <b>return</b> out;
}

int <b>main</b>(int argc, char* argv[])
{
    double x[] = { 1.0, 2.0, 3.0};
    double y[] = {10.0,11.0,12.0};
    list&lt;double&gt; <b>a</b>(x,x+<b>sizeof</b>(x)/<b>sizeof</b>(double));
    list&lt;double&gt; <b>b</b>(y,y+<b>sizeof</b>(y)/<b>sizeof</b>(double));
    list&lt;double&gt; c;

    c = a+b;

    <b>copy</b>(c.<b>begin</b>(),c.<b>end</b>(),ostream_iterator&lt;double&gt;(cout, "\n"));

    <b>return</b> 0;
}
</pre>

<p></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-17</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Wed, 10 Jan 2007 17:58:53 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-17</guid>
		<description>&lt;p&gt;What I meant by type compatibility is that the compiler is able to determine that a type has a specific interface (in your example, that it understands the + operator) without any sort of explicit declaration.&lt;/p&gt;

&lt;p&gt;In short, your example is exactly what I meant. Thanks.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>What I meant by type compatibility is that the compiler is able to determine that a type has a specific interface (in your example, that it understands the + operator) without any sort of explicit declaration.</p>

<p>In short, your example is exactly what I meant. Thanks.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Buchholz</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-16</link>
		<dc:creator>Greg Buchholz</dc:creator>
		<pubDate>Wed, 10 Jan 2007 15:56:16 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-16</guid>
		<description>&lt;blockquote&gt;I assume you’re referring to type compatibility in those static type systems?&lt;/blockquote&gt;

&lt;p&gt;If by &quot;type compatibility&quot; you mean types that can substitute for one another &lt;em&gt;everywhere&lt;/em&gt;, then no.  In Haskell, for example, you can create a function...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;pre&gt;
double x = x+x
&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;...which can be passed anything that understands the plus operator.  So lets make lists of numbers understand &quot;plus&quot;...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;pre&gt;
instance Num a =&gt; Num [a] where (+) = zipWith (+)
&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;...now let&#039;s try it out at the REPL...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;pre&gt;
$ ghci type_compat.hs 
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  &#124; &#124;      GHC Interactive, 6.6, for Haskell 98.
/ /_\\/ __  / /___&#124; &#124;      http://www.haskell.org/ghc/
\____/\/ /_/\____/&#124;_&#124;      Type :? for help.

Loading package base ... linking ... done.
[1 of 1] Compiling Main          ( type_compat.hs, interpreted )

Ok, modules loaded: Main.
*Main&gt; double 4.0
8.0
*Main&gt; double 42
84
*Main&gt; double [1,2,3]
[2,4,6]
*Main&gt;
&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;...so you can use floating point numbers and lists of integers in &lt;em&gt;some&lt;/em&gt; of the same places, but I don&#039;t think they&#039;d be called compatible types.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<blockquote>I assume you’re referring to type compatibility in those static type systems?</blockquote>

<p>If by &#8220;type compatibility&#8221; you mean types that can substitute for one another <em>everywhere</em>, then no.  In Haskell, for example, you can create a function&#8230;</p>

<p><code><pre>
double x = x+x
</pre></code></p>

<p>&#8230;which can be passed anything that understands the plus operator.  So lets make lists of numbers understand &#8220;plus&#8221;&#8230;</p>

<p><code><pre>
instance Num a =&gt; Num [a] where (+) = zipWith (+)
</pre></code></p>

<p>&#8230;now let&#8217;s try it out at the REPL&#8230;</p>

<p><code><pre>
$ ghci type_compat.hs 
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, 6.6, for Haskell 98.
/ /_\\/ __  / /___| |      <a href="http://www.haskell.org/ghc/" rel="nofollow">http://www.haskell.org/ghc/</a>
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
[1 of 1] Compiling Main          ( type_compat.hs, interpreted )

Ok, modules loaded: Main.
*Main&gt; double 4.0
8.0
*Main&gt; double 42
84
*Main&gt; double [1,2,3]
[2,4,6]
*Main&gt;
</pre></code></p>

<p>&#8230;so you can use floating point numbers and lists of integers in <em>some</em> of the same places, but I don&#8217;t think they&#8217;d be called compatible types.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-15</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Wed, 10 Jan 2007 04:13:55 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-15</guid>
		<description>&lt;p&gt;I assume you&#039;re referring to type compatibility in those static type systems?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I assume you&#8217;re referring to type compatibility in those static type systems?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Buchholz</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-14</link>
		<dc:creator>Greg Buchholz</dc:creator>
		<pubDate>Tue, 09 Jan 2007 22:00:53 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-14</guid>
		<description>&lt;blockquote&gt;In your C++ example, is the type of the function still checked statically?&lt;/blockquote&gt;

&lt;p&gt;Yes.  I don&#039;t think I&#039;ve ever seen a formal definition of &lt;a href=&quot;http://en.wikipedia.org/wiki/Duck_typing&quot; rel=&quot;nofollow&quot;&gt;duck&lt;/a&gt; &lt;a href=&quot;http://mindview.net/WebLog/log-0052&quot; rel=&quot;nofollow&quot;&gt;typing&lt;/a&gt;, but C++ templates certainly allow you to treat anything that quacks and waddles as a duck, while still making sure your type mismatches are detected at compile time.  Same goes for Haskell, &lt;a href=&quot;http://clean.cs.ru.nl/&quot; rel=&quot;nofollow&quot;&gt;Clean&lt;/a&gt;, etc.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<blockquote>In your C++ example, is the type of the function still checked statically?</blockquote>

<p>Yes.  I don&#8217;t think I&#8217;ve ever seen a formal definition of <a href="http://en.wikipedia.org/wiki/Duck_typing" rel="nofollow">duck</a> <a href="http://mindview.net/WebLog/log-0052" rel="nofollow">typing</a>, but C++ templates certainly allow you to treat anything that quacks and waddles as a duck, while still making sure your type mismatches are detected at compile time.  Same goes for Haskell, <a href="http://clean.cs.ru.nl/" rel="nofollow">Clean</a>, etc.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://dubroy.com/blog/on-static-and-dynamic-typing-and-corn-tortillas/comment-page-1/#comment-13</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Tue, 09 Jan 2007 21:14:42 +0000</pubDate>
		<guid isPermaLink="false">http://dubroy.com/blog/2007/01/08/on-static-and-dynamic-typing-and-corn-tortillas/#comment-13</guid>
		<description>&lt;p&gt;Thanks for the pointers. You&#039;re right, I should take a look at those languages. I have poked around with Haskell and OCaml, but only the tiniest bit.&lt;/p&gt;

&lt;p&gt;In your C++ example, is the type of the function still checked statically?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for the pointers. You&#8217;re right, I should take a look at those languages. I have poked around with Haskell and OCaml, but only the tiniest bit.</p>

<p>In your C++ example, is the type of the function still checked statically?</p>]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->