<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by sylvan</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/sylvan/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by sylvan</title>
		<link>http://channel9.msdn.com/Niners/sylvan/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/sylvan/Discussions</link>
	<language>en</language>
	<pubDate>Thu, 23 May 2013 03:57:47 GMT</pubDate>
	<lastBuildDate>Thu, 23 May 2013 03:57:47 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Coffeehouse - Interviewing programmers</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">evildictaitor wrote:</div>
<div class="quoteBody">&#65279;<br>
<br>
In ASM a delegate is any memory length of n bits that is addressable<br>
In C a delegate is a size_t, which is an int or long or long long depending on the processor size.<br>
In C&#43;&#43; a delegate is not significantly changed from C, but it is type-checked at compile time.<br>
In C# a delegate is a C&#43;&#43; function pointer which is (and I <a href="http://msdn2.microsoft.com/en-us/library/900fyy8e%28VS.71%29.aspx">
quote</a>)<br>
<i>Delegates are roughly similar to function pointers in C&#43;&#43;; however, delegates are type-safe and secure.</i><br>
</div>
</blockquote>
<br>
<br>
You can do the same trick with, for example, &quot;a class&quot; (&quot;in ASM a class is a slab of memory&quot;.. etc.), doesn't make it true. A delegate, which is a C# concept, is only very superficially similar to a function pointer, but is really nothing like it. Like I explained,
 a delegate is a lexical closure, which is pretty isomorphic to classes (you can model one with the other). A function pointer is just a way of doing an indirect function call. Very, very different.<br>
<br>
The fact that delegates are also type safe etc. is nice and all, but that's not the key difference.<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/6af2b51c36254aafaa539dec00a12708#6af2b51c36254aafaa539dec00a12708</link>
		<pubDate>Wed, 22 Aug 2007 21:48:58 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/6af2b51c36254aafaa539dec00a12708#6af2b51c36254aafaa539dec00a12708</guid>
		<dc:creator>sylvan</dc:creator>
		<slash:comments>80</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/sylvan/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - Interviewing programmers</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">AndyC wrote:</div>
<div class="quoteBody">&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>Ion Todirel wrote:</strong>
<hr size="1">
<i>&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>evildictaitor wrote:</strong>
<hr size="1">
<i>&#65279;<br>
<br>
*<font color="#0000ff">void.<br>
<br>
</font></i></td>
</tr>
</tbody>
</table>
</blockquote>
good answer, you're hired<br>
</i></td>
</tr>
</tbody>
</table>
</blockquote>
<br>
<br>
Not really, delegates are more than just function pointers. They offer type safety and security as they always point to a method, which a *void may well not do.</div>
</blockquote>
<br>
<br>
And above all, they capture variables (proper lexical closures, in other words)! Comparing with function pointer is useful if and only if the next sentence out of your mouth is &quot;but they're really completely different&quot;.<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/ed3b76fc0f964f149c419dec00a12589#ed3b76fc0f964f149c419dec00a12589</link>
		<pubDate>Wed, 22 Aug 2007 18:22:20 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/ed3b76fc0f964f149c419dec00a12589#ed3b76fc0f964f149c419dec00a12589</guid>
		<dc:creator>sylvan</dc:creator>
		<slash:comments>80</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/sylvan/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - Interviewing programmers</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">evildictaitor wrote:</div>
<div class="quoteBody">&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>AndyC wrote:</strong>
<hr size="1">
<i>&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>Ion Todirel wrote:</strong>
<hr size="1">
<i>&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>evildictaitor wrote:</strong>
<hr size="1">
<i>&#65279;<br>
<br>
*<font color="#0000ff">void.<br>
<br>
</font></i></td>
</tr>
</tbody>
</table>
</blockquote>
good answer, you're hired<br>
</i></td>
</tr>
</tbody>
</table>
</blockquote>
<br>
<br>
Not really, delegates are more than just function pointers. They offer type safety and security as they always point to a method, which a *void may well not do.</i></td>
</tr>
</tbody>
</table>
</blockquote>
<br>
<br>
The type-safety is only at compile time (for non .NET languages), so actually what a delegate
<i><b>is </b></i>is a *void.<br>
<br>
Even in .NET it's just a typedef wrapper on a System.IntPtr.<br>
</div>
</blockquote>
<br>
<br>
NO! A delegate is a tiny object that captures any variables in scope at the definition (that are also used in the definition). It's NOT anywhere close to a function pointer, it's more like a quick one-off class with a single method.<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/c7610719b6a84d4289019dec00a125b6#c7610719b6a84d4289019dec00a125b6</link>
		<pubDate>Wed, 22 Aug 2007 18:18:07 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/c7610719b6a84d4289019dec00a125b6#c7610719b6a84d4289019dec00a125b6</guid>
		<dc:creator>sylvan</dc:creator>
		<slash:comments>80</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/sylvan/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - Interviewing programmers</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">Dr Herbie wrote:</div>
<div class="quoteBody">&#65279;OK, firstly polymorphism has nothing to do with code-reuse.&nbsp; That's where you're confusing class inheritance with polymorphism (although you're right, polymorphism does depend on inheritance).<br>
</div>
</blockquote>
<br>
<br>
No, that's wrong. Value based dispatch depends on inheritance, polymorphism does not. Polymorphism does have something to do with code reuse preciesly because you can write a function that works on values of multiple types.<br>
<br>
Here's a polymorhic method that doesn't depend on inheritance in the least:<br>
<br>
<br>
<font face="Courier New">static T pickFirst&lt;T&gt;(T a, T b)<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return a;<br>
}<br>
<br>
<font face="Times New Roman"><font face="Verdana">Normally this isn't very useful, you'd have to constrain the template parameter somehow (and obviously you'd do that using interfaces, and you might almost be able to claim that interfaces depend on inheritance,
 but that would also be wrong - consider something like Haskell that has no inheritance but manages to have a type hierarchy and polymorphism anyway; by simply using type-based dispatch rather than value-based dispatch). Consider something like</font><br>
<br>
<font color="#000000" face="Courier New">static uint length&lt;T&gt;( MyList&lt;T&gt; list )<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return list.IsEmpty ? 0 : 1 &#43; length( list.tail);<br>
}</font><br>
<br>
<font face="Verdana">This is a much more useful function that does not depend on inheritance either, and would still be exceedingly polymorphic in that it can work on lists of any element type (in this case an immutable singly linked list).<br>
<br>
So yeah, inheritance is one way of doing subtyping, but not the only way of doing polymorphism.</font><br>
</font></font></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/8b83a147a8764a43bcbb9dec00a1255e#8b83a147a8764a43bcbb9dec00a1255e</link>
		<pubDate>Wed, 22 Aug 2007 18:05:48 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257126-Interviewing-programmers/8b83a147a8764a43bcbb9dec00a1255e#8b83a147a8764a43bcbb9dec00a1255e</guid>
		<dc:creator>sylvan</dc:creator>
		<slash:comments>80</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/sylvan/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>