Method Pointers
Ben Evans
benjamin.john.evans at gmail.com
Sun Mar 25 15:25:09 PDT 2012
On Sun, Mar 25, 2012 at 7:11 PM, Neal Gafter <neal at gafter.com> wrote:
> On Sun, Mar 25, 2012 at 10:20 AM, Ben Evans <benjamin.john.evans at gmail.com>
> wrote:
>>
>> On Sun, Mar 25, 2012 at 2:23 AM, Neal Gafter <neal at gafter.com> wrote:
>> > The C# compiler goes to a tiny bit of trouble to make it so that in some
>> > cases when you evaluate the very same lambda expression twice (not
>> > written
>> > twice, but written once and evaluated twice) you get the same object.
>> > But
>> > you can't rely on it.
>>
>> Um, why?
>
> What is your question? Why does it do that, or why can't you rely on it?
The question was actually: "Why would you have that as a deliberate
feature?", but your later commentary seems to shed some light on this.
>> What's the rationale for having a feature which only works some of the
>> time, and
>> furthermore seems to only work in cases that overlap a lot with "cases
>> beginners
>> would try out, and then draw entirely wrong conclusions from"?
>
> The "feature" is to generate more compact or efficient code when it is easy
> to do so. We do that because it improves the performance of programs
> written by our customers. Solving the general problem is not possible,
> which is why we don't always collapse equivalent lambdas.
OK, so this is simply an implementation hack, which happens to improve
performance, and has the side effect of probably confusing new users,
rather than a deliberate, unreliable design feature?
Ben
More information about the lambda-dev
mailing list