﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Krzysztof Koźmic commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>I now your pain, earlier this week, I've been trying to come up with nicer, and more strongly typed ways to cope with events in Rhino.Mocks (strongly typed EventRaiser, event subscribtion and verification) and I failed miserably. I think I just gave up (at least for now). You can see the attempts at my blog.
  
And BTW, why are delegates so limited in cooperation with generics? :/ It's just annoying
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment8</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment8</guid><pubDate>Fri, 21 Mar 2008 07:05:37 GMT</pubDate></item><item><title>Jay commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>Execute((t, k) =&gt; Bar(t, k));
  
Execute((t, k) =&gt; Foo(t, k));
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment7</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment7</guid><pubDate>Thu, 20 Mar 2008 18:26:47 GMT</pubDate></item><item><title>Justin Etheredge commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>Let me also say that they could have enabled this for very simple scenarios such as the one you are dealing with. In the blog post by Eric Lippert referenced above he basically says that they could have done it in certain scenarios, but in other scenarios it would have been impossible. He said that they didn't want two different inference algorithms that produce slightly different results. While I am certainly not a compiler writer, that sounds like they are taking an idealistic approach and not a pragmatic one. The pragmatic approach would have been to try and make type inference work in as many different scenarios as possible, and have it fail when the resolution is unreachable.
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment6</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment6</guid><pubDate>Thu, 20 Mar 2008 12:23:38 GMT</pubDate></item><item><title>Justin Etheredge commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>If you swap the bool on the end to Func&lt;T, K, bool&gt; then everything except for Execute(Bar) and Execute(Foo) works. And I agree with Frans, I have heard all the explanations about why it wouldn't work, but I wish they could have found a way to make it work.
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment5</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment5</guid><pubDate>Thu, 20 Mar 2008 12:06:22 GMT</pubDate></item><item><title>Frans Bouma commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>Yes, this is pretty annoying. I ran into this as well when I wanted to introduce some types for prefetchpath specifications inside linq queries and wanted to get rid of the explicit generic argument specifications... IMHO it's a compiler flaw, no matter how many excuses they invent: they introduced syntactic sugar, then make the compiler deal with that in all cases. 
  
  
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment4</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment4</guid><pubDate>Thu, 20 Mar 2008 08:39:18 GMT</pubDate></item><item><title>Steve commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>Lambda stuff is nice but I would love to see Boo DSL for rhino mocks :)
  
  
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment3</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment3</guid><pubDate>Thu, 20 Mar 2008 07:55:50 GMT</pubDate></item><item><title>ychebotarev commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>public static void Execute&lt;T, K&gt;(Func&lt;bool, T, K&gt; e)
  
should be 
  
public static void Execute&lt;T, K&gt;(Func&lt;T, K,bool&gt; e)
  
  
:)
  
  
after that there will be errors only with
  
Execute(Bar);
  
Execute(Foo);
  
  
you can rewrite this as 
  
            Action&lt;int, string&gt; bar_ptr = Bar;
  
            Execute(bar_ptr); // compiles fine
  
            Func&lt;int, string, bool&gt; foo_ptr = Foo;
  
            Execute(foo_ptr);// compiles fine
  
  
Here is big explanation why type inference didn't work in this case:
  
http://blogs.msdn.com/ericlippert/archive/2007/11/05/c-3-0-return-type-inference-does-not-work-on-member-groups.aspx
  
  
But for me that was not very convincing.
  
  
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment2</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment2</guid><pubDate>Thu, 20 Mar 2008 07:22:58 GMT</pubDate></item><item><title>Jay commented on Csc.exe and delegate inference, or: Why C# has awkward syntax</title><description>Maybe you were looking for Func&lt;T, K, bool&gt;?
</description><link>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment1</link><guid>http://ayende.com/3199/csc-exe-and-delegate-inference-or-why-c-has-awkward-syntax#comment1</guid><pubDate>Thu, 20 Mar 2008 07:02:27 GMT</pubDate></item></channel></rss>