<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Fast Late-Bound Invocation with Expression Trees</title>
	<atom:link href="http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/feed/" rel="self" type="application/rss+xml" />
	<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/</link>
	<description>Rambling and occasional wisdom from Nate Kohari</description>
	<lastBuildDate>Thu, 21 Jul 2011 13:50:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Tor Arvid Lund</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-322</link>
		<dc:creator><![CDATA[Tor Arvid Lund]]></dc:creator>
		<pubDate>Thu, 19 Aug 2010 23:46:03 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-322</guid>
		<description><![CDATA[Ahh! Fantastic! This was just what I was looking for. After pulling my hair for hours, your little example helped me solve my issue in about 20 minutes.

Thanks a million!]]></description>
		<content:encoded><![CDATA[<p>Ahh! Fantastic! This was just what I was looking for. After pulling my hair for hours, your little example helped me solve my issue in about 20 minutes.</p>
<p>Thanks a million!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elegant Code &#187; CreateDelegate&#60;T&#62; &#8211; An Exercise in Using Expressions</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-321</link>
		<dc:creator><![CDATA[Elegant Code &#187; CreateDelegate&#60;T&#62; &#8211; An Exercise in Using Expressions]]></dc:creator>
		<pubDate>Fri, 30 Jul 2010 22:32:05 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-321</guid>
		<description><![CDATA[[...] going to outperform&#160; Delegate.CreateDelegate(). In fact, if you’re interested have a look at this approach first as it seems much faster. I added some spike code to the Elegant Code repository for those who [...] ]]></description>
		<content:encoded><![CDATA[<p>[...] going to outperform&#160; Delegate.CreateDelegate(). In fact, if you’re interested have a look at this approach first as it seems much faster. I added some spike code to the Elegant Code repository for those who [...] </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ameesh</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-320</link>
		<dc:creator><![CDATA[Ameesh]]></dc:creator>
		<pubDate>Mon, 01 Mar 2010 18:43:37 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-320</guid>
		<description><![CDATA[Great work !

However while I can get this to work with most method calls, it doesnt seem to work with methods that dont have a return value. (void methods).. ?]]></description>
		<content:encoded><![CDATA[<p>Great work !</p>
<p>However while I can get this to work with most method calls, it doesnt seem to work with methods that dont have a return value. (void methods).. ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AGS SOE’s without the SOAP &#8211; v2 &#171; MapWrecker 2.0</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-319</link>
		<dc:creator><![CDATA[AGS SOE’s without the SOAP &#8211; v2 &#171; MapWrecker 2.0]]></dc:creator>
		<pubDate>Thu, 14 Jan 2010 09:18:57 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-319</guid>
		<description><![CDATA[[...] however, is hardly the fastest way to dynamically invoke methods. Nate Kohari shows how to use LINQ expressions to create fast invokers for late-bound methods. Rick Strahl [...] ]]></description>
		<content:encoded><![CDATA[<p>[...] however, is hardly the fastest way to dynamically invoke methods. Nate Kohari shows how to use LINQ expressions to create fast invokers for late-bound methods. Rick Strahl [...] </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-299</link>
		<dc:creator><![CDATA[JP]]></dc:creator>
		<pubDate>Sat, 20 Jun 2009 09:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-299</guid>
		<description><![CDATA[I think you&#039;re idea is great. I&#039;ve faced the same problem in the past and I completely missed the possibility of using lambda expressions.

Although I have no doubts that your solution works and is fast enough, I see some room for improvement.

First thing, you can add the &#039;params&#039; keyword to the LateBoundMethod delegate like that:
public delegate object LateBoundMethod(object target, params object[] arguments);

With this, it&#039;s not necessary to explicitly create an array when calling the delegate. For example, you could write:
bool result = (bool) callback(foo, &quot;this&quot;);
instead of:
bool result = (bool) callback(foo, new[] { &quot;this&quot; });

My second point is more relevant. I was worried about argument validation. For example, what would happen if someone calls a LateBoundMethod passing an incorrect number of parameters? Or if arguments = null?

Better than simply asking, I tested it. The asnwers were IndexOutOfRangeException and NullReferenceException, respectively. Both exceptions are somewhat ugly for a grownup component to throw. IMHO, the more &quot;correct&quot; exceptions would be TargetParameterCountException and ArgumentNullException.

I went ahead and tried to implement this change. I think I&#039;ve reached a reasonable solution. Of course, argument validation will slow down the execution a bit for both generation and calling. Anyway, I believe any mature code should do this.

Nate, if you don&#039;t mind, I&#039;ll post my solution on my blog. Naturally, with a very big reference to the original author. In the meantime, if anyone is interested in seeing my code, send me an email (jpbochi at gmail dot com).]]></description>
		<content:encoded><![CDATA[<p>I think you&#8217;re idea is great. I&#8217;ve faced the same problem in the past and I completely missed the possibility of using lambda expressions.</p>
<p>Although I have no doubts that your solution works and is fast enough, I see some room for improvement.</p>
<p>First thing, you can add the &#8216;params&#8217; keyword to the LateBoundMethod delegate like that:<br />
public delegate object LateBoundMethod(object target, params object[] arguments);</p>
<p>With this, it&#8217;s not necessary to explicitly create an array when calling the delegate. For example, you could write:<br />
bool result = (bool) callback(foo, &#8220;this&#8221;);<br />
instead of:<br />
bool result = (bool) callback(foo, new[] { &#8220;this&#8221; });</p>
<p>My second point is more relevant. I was worried about argument validation. For example, what would happen if someone calls a LateBoundMethod passing an incorrect number of parameters? Or if arguments = null?</p>
<p>Better than simply asking, I tested it. The asnwers were IndexOutOfRangeException and NullReferenceException, respectively. Both exceptions are somewhat ugly for a grownup component to throw. IMHO, the more &#8220;correct&#8221; exceptions would be TargetParameterCountException and ArgumentNullException.</p>
<p>I went ahead and tried to implement this change. I think I&#8217;ve reached a reasonable solution. Of course, argument validation will slow down the execution a bit for both generation and calling. Anyway, I believe any mature code should do this.</p>
<p>Nate, if you don&#8217;t mind, I&#8217;ll post my solution on my blog. Naturally, with a very big reference to the original author. In the meantime, if anyone is interested in seeing my code, send me an email (jpbochi at gmail dot com).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: More on Late-Bound Invocations with Expression Trees - Jimmy Bogard -</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-298</link>
		<dc:creator><![CDATA[More on Late-Bound Invocations with Expression Trees - Jimmy Bogard -]]></dc:creator>
		<pubDate>Thu, 18 Jun 2009 01:04:50 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-298</guid>
		<description><![CDATA[[...] it all looks quite ugly and hard to maintain.&#160; Until I stumbled upon Nate Kohari’s post on late-bound invocations via expression trees, I was avoiding that piece.&#160; The basic idea is that expression trees, when compiled, are able [...] ]]></description>
		<content:encoded><![CDATA[<p>[...] it all looks quite ugly and hard to maintain.&#160; Until I stumbled upon Nate Kohari’s post on late-bound invocations via expression trees, I was avoiding that piece.&#160; The basic idea is that expression trees, when compiled, are able [...] </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate Kohari</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-297</link>
		<dc:creator><![CDATA[Nate Kohari]]></dc:creator>
		<pubDate>Wed, 11 Mar 2009 13:16:57 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-297</guid>
		<description><![CDATA[@Klaus: That&#039;s true, with a language that supports dynamic dispatch, this would be simpler. However, the whole concept is to *reduce* the cost of late-bound invocation. Using Ruby, you pay a much higher price on *every* invocation, since the compiler can&#039;t determine the method bindings at compile-time.

This isn&#039;t to say Ruby isn&#039;t a great language, but it&#039;s also not the &quot;next step&quot; in programming -- it&#039;s just a different way of thinking that happens to have become more popular in recent years.]]></description>
		<content:encoded><![CDATA[<p>@Klaus: That&#8217;s true, with a language that supports dynamic dispatch, this would be simpler. However, the whole concept is to *reduce* the cost of late-bound invocation. Using Ruby, you pay a much higher price on *every* invocation, since the compiler can&#8217;t determine the method bindings at compile-time.</p>
<p>This isn&#8217;t to say Ruby isn&#8217;t a great language, but it&#8217;s also not the &#8220;next step&#8221; in programming &#8212; it&#8217;s just a different way of thinking that happens to have become more popular in recent years.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klaus Hebsgaard</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-296</link>
		<dc:creator><![CDATA[Klaus Hebsgaard]]></dc:creator>
		<pubDate>Wed, 11 Mar 2009 09:13:36 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-296</guid>
		<description><![CDATA[I remember when I coded C++ how memory management was a big issue, and I found it very exciting, and very nerdy.
In C++ people would do big (I mean BIG) work to make automatic memory management instead of running new() and delete() all the time.
And I remember thinking when I started coding C# that all this garbage collection was just for people who didn&#039;t understand to code.
However I dit grow wiser and now understand how C# raised the bar (abstraction) for me so I didn&#039;t have to do technically challenging and nerdy stuff, but simply use the right tool (.Net) for the right job.
I see the same thing here, what you are trying to do would be very easy and simple to do in a dynamic language like Ruby...]]></description>
		<content:encoded><![CDATA[<p>I remember when I coded C++ how memory management was a big issue, and I found it very exciting, and very nerdy.<br />
In C++ people would do big (I mean BIG) work to make automatic memory management instead of running new() and delete() all the time.<br />
And I remember thinking when I started coding C# that all this garbage collection was just for people who didn&#8217;t understand to code.<br />
However I dit grow wiser and now understand how C# raised the bar (abstraction) for me so I didn&#8217;t have to do technically challenging and nerdy stuff, but simply use the right tool (.Net) for the right job.<br />
I see the same thing here, what you are trying to do would be very easy and simple to do in a dynamic language like Ruby&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Strahl</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-301</link>
		<dc:creator><![CDATA[Rick Strahl]]></dc:creator>
		<pubDate>Tue, 10 Mar 2009 22:05:24 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-301</guid>
		<description><![CDATA[Nate - after running some perf tests on this I&#039;m not sure if it&#039;s worth it to do this, unless you make a boat load of calls against your dynamic delegate (and this might make good sense in nInject).

The compilation of the delegate is wickedly expensive - in my tests you&#039;d have to make somewhere around 2500 Reflection calls to make up for the compilation overhead. Perf is super fast once you have the compiled delegate, but it&#039;s heavy price to pay up front.

Here&#039;s what I played with:
http://www.west-wind.com/weblog/posts/653034.aspx]]></description>
		<content:encoded><![CDATA[<p>Nate &#8211; after running some perf tests on this I&#8217;m not sure if it&#8217;s worth it to do this, unless you make a boat load of calls against your dynamic delegate (and this might make good sense in nInject).</p>
<p>The compilation of the delegate is wickedly expensive &#8211; in my tests you&#8217;d have to make somewhere around 2500 Reflection calls to make up for the compilation overhead. Perf is super fast once you have the compiled delegate, but it&#8217;s heavy price to pay up front.</p>
<p>Here&#8217;s what I played with:<br />
<a href="http://www.west-wind.com/weblog/posts/653034.aspx" rel="nofollow">http://www.west-wind.com/weblog/posts/653034.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simone Busoli</title>
		<link>http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-295</link>
		<dc:creator><![CDATA[Simone Busoli]]></dc:creator>
		<pubDate>Mon, 09 Mar 2009 17:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/#comment-295</guid>
		<description><![CDATA[I won&#039;t go over your reply. Let me just say that you look like a skilled verbalist, and your replies to my comments were mostly out of context.
I know what you&#039;re talking about, it&#039;s just very badly exposed.]]></description>
		<content:encoded><![CDATA[<p>I won&#8217;t go over your reply. Let me just say that you look like a skilled verbalist, and your replies to my comments were mostly out of context.<br />
I know what you&#8217;re talking about, it&#8217;s just very badly exposed.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

