C#3.0 and lambdas

Robert Kern rkern at ucsd.edu
Wed Sep 21 12:15:00 EDT 2005


Christophe wrote:
> Steve Holden a écrit :
>>and consequently the second version of drawline is exactly equivalent to 
>>the first. So, if the second one is useless then so is the first.
> 
> Well, sorry about that but you are perfectly right. The point I was 
> trying to defend though was that such construct is very uncommon. It 
> isn't always possible to unpack the tuples like that because you usually 
> need all the info at once.

Many, many drawing APIs use a Postscript-like model such that drawing a
line from p1 to p2 decomposes into something like this:

    moveto(p1)
    lineto(p2)

Almost always those are methods on some object that maintains the state
(no globals in sight):

    gc.moveto(p1)
    gc.lineto(p2)

I think it's much more common than you realize. You are right that there
are plenty of functions that you might want to call that would require
something like this:

   low_level_drawline(x1, y1, x2, y2)

that isn't amenable to *argument unpacking.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list