Re: Lambda expressions: Dangerous Madness
- From: Barry Kelly <barry.j.kelly@xxxxxxxxx>
- Date: Fri, 15 Aug 2008 02:59:31 +0100
Pavel Minaev wrote:
signalling callbacks). So I do this:
list.Sort((x, y) => x - y);
Beware of overflow: this is not a good comparison function. E.g. see:
using System;
class App
{
static void Main()
{
int a = int.MaxValue - 3;
int b = int.MinValue + 3; // so a > b, right?
Console.WriteLine("a = {0}, b = {1}, a > b = {2}", a, b, a > b);
Console.WriteLine(a - b); // so this is positive, right?
// a - b = -7 => oops!
}
}
stream.BeginRead(
buffer,
offset,
count,
delegate(IAsyncResult ar)
{
...
},
null);
This manual continuation-passing style cries out for a machine
translation. I've still got this one on my todo list...
-- Barry
--
http://barrkel.blogspot.com/
.
- Follow-Ups:
- Re: Lambda expressions: Dangerous Madness
- From: Pavel Minaev
- Re: Lambda expressions: Dangerous Madness
- From: Jon Skeet [C# MVP]
- Re: Lambda expressions: Dangerous Madness
- References:
- Lambda expressions: Dangerous Madness
- From: raylopez99
- Re: Lambda expressions: Dangerous Madness
- From: Jon Skeet [C# MVP]
- Re: Lambda expressions: Dangerous Madness
- From: Peter Morris
- Re: Lambda expressions: Dangerous Madness
- From: raylopez99
- Re: Lambda expressions: Dangerous Madness
- From: Pavel Minaev
- Lambda expressions: Dangerous Madness
- Prev by Date: Re: C#--is it growing? Or saturated? (Charles Petzold does C#)
- Next by Date: Re: C#--is it growing? Or saturated? (Charles Petzold does C#)
- Previous by thread: Re: Lambda expressions: Dangerous Madness
- Next by thread: Re: Lambda expressions: Dangerous Madness
- Index(es):
Relevant Pages
|