title: How to force a delegate type to not hold any information?
body: <p>I am designing an API that is very comparable to Linq (it's a linq that acts on more complex objects) and I have some client developers who don't quite get the philosophy behind it. I would like to prevent them from doing some things, so that their code is more in line with what the API is all about. So for the examples I will just refer to Linq.</p>
  
  <p>In very short, what I see in the client code is something similar to:</p>
  
  <pre><code>IEnumerable&lt;double&gt; xlist;
  IEnumerable&lt;double&gt; ylist;
  var zlist = xlist.Select( (x,i) =&gt; x + ylist.ElementAt(i) );
  </code></pre>
  
  <p>This is really bad, and rather than me having to tell people that they are misbehaving, I would like to force my clients to write this instead:</p>
  
  <pre><code>var zlist = xlist.Zip(ylist, (x,y) =&gt; x + y);
  </code></pre>
  
  <p>So after thinking about it, I figured that what I would really want for my API, is to prevent clients from "injecting" data into delegate types. In other words, I would like to define extension methods, such as:</p>
  
  <pre><code>IEnumerable&lt;TResult&gt; MySelect&lt;TSource, TResult&gt;(
                                  this IEnumerable&lt;TSource&gt; source,
                                  StaticFunc&lt;TSource, int, TResult&gt; selector)
  </code></pre>
  
  <p>where StaticFunc would be some kind of delegate type that doesn't hold any data (or at most that would only static-context data).</p>
  
  <p>Can anyone see a way to do that?</p>