| Joe Walnes |
|
|||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||
|
The power of closures in C# 2.0Martin Fowler (obligitary Fowlbot namedrop) recently blogged about the power of closures in languages that support them. It's worth remembering that C# 2.0 has true closure support in the form of anonymous delegates. This includes reading and modifying variables outside the context of the closure - unlike Java's anonymous inner classes. Just for kicks, I've rewritten all of the examples Martin's Ruby examples in C# 2.0. This makes use of the improved APIs in .NET 2.0 pointed out by Zohar.
The code difference between the languages isn't that difference. The C# 2.0 code is obviously longer (though not a lot) because:
You can try this stuff out yourself by playing with Visual C# Express.
CommentsObieCool, but what's with the capitalized method names? ICK!!! ZoharI only wish Resharper would work with Visual C# Express. Joe WalnesHere is a sample comparison of anonymous delegates in C# 2.0 with anonymous inner classes in Java. C# 2.0 int total = 0; Java final int[] total = { 0 }; This is something I end up doing a lot, and I cringe everytime. The anonymous bloat I don't mind so much, but the final array hack is what really gets me. This is necessary because any local variable outside the scope the of the inner must be final, so the only way to write to it is to use an array. Thankfully IDEA always automagically sorts this out for me, but it's still confusing for someone who is later trying to understand the code. verbatI said many times: c# 2.0 is a kind of statically typed ruby. Even the icollection apis wich gets anonimous delegates as parameters really resemble ruby's Enumerable. Pavel TavodaIf you want use scripting languages, go with Groovy. This have very extended closure support. Meitsi"The C# 2.0 code is obviously longer (though not a lot) because: C# 2.0 is staticly typed (let's not get started on the static vs dynamic debate)." No, not quite the right reason. C# is longer specifically because it uses manifest typing. Eric HodelEeee! The code runs all over the sidebar. Unreadable even at 1024 px width! Try putting such code blocks in a div with the style "overflow:auto" set Yuriyjust to remind that JScript supports this technique small sample: var A(1); The example code is wrong, I think. Shouldn't the FindAll example actually be:
Bill WoodI've put boo versions of these examples here: Boo is a new object oriented statically typed programming language for the Common Language Infrastructure with a python inspired syntax and a special focus on language and compiler extensibility. Bill WoodSorry the second link above to boo should be: JayI would like to check this out, but I can't read the C# because it drools out into the right sidebar. David VallnerMinor note by a rubyist - the Ruby code examples don't make use of omitting the return keyword. If you used return inside a closure, it would return from the method it was defined in. ChrisPlease God fix the messed up tables created by SiteMash and UnmoveableType so I can read this example. Thomas HafnerQuote: Static typing is a bad excuse for longer code. It's not obvious at f x = (\y -> x + y) It's a closure (see ). Nevertheless Haskel is a statically typed language (see table "Type Regards Thomas HafnerSorry that I've to post it again, but the Blog software skipped the Quote: Static typing is a bad excuse for longer code. It's not obvious at f x = (\y -> x + y) It's a closure (see http://www.haskell.org/hawiki/Closure). Nevertheless Haskell is a statically typed language (see table "Type Regards EricEssential C# 2.0 online pharmacyonline pharmacy viagratcx
levitraziw
viagravyc
viagragrp
viagrayqd
viagrahry
viagrapsl
levitra
alibabameGood-girl-turned-bad Britney Spears has topped an eclectic list of the net’s most popular searches sotiriconThis is all you car. azazello.Hi!Q Sten62494Not much on my mind. I don't care. I've just been letting everything happen without me , but shrug. Whatever. I feel like a void. Sten99336I've just been hanging out not getting anything done. What can I say? I've basically been doing nothing worth mentioning, but pfft. Not that it matters. Pretty much nothing exciting happening to speak of. I haven't been up to much these days. jessicaholinIt can assist men with this disorder in achieving and maintaining an erection during sexual activity Sten18318Not much on my mind these days, but what can I say? It's not important. I just don't have much to say lately. I've just been letting everything pass me by recently, but eh. wendywonderGood day! Sten27662My mind is like a bunch of nothing, but I guess it doesn't bother me. I haven't been up to anything recently. I've pretty much been doing nothing to speak of. Sten31876Not much on my mind right now, but it's not important. I've just been letting everything happen without me. I just don't have anything to say right now. Sten91389retty much nothing seems worth thinking about. My life's been completely dull , not that it matters. I've just been staying at home waiting for something to happen. ProgonkaOneNSU - 4efer, 5210 - rulez Sten80090I haven't been up to much today. I've just been letting everything happen without me. Basically nothing seems worth bothering with. I've just been hanging out doing nothing. I just don't have anything to say right now. More or less nothing happening. Sten45965I feel like a complete blank, but I don't care. Pfft. I've pretty much been doing nothing worth mentioning. mygirlisgoodHello! Sten2926I haven't been up to much these days. Today was a loss. Nothing seems important. I've just been letting everything happen without me these days. Sten92364I can't be bothered with anything these days, but shrug. I just don't have anything to say recently. I haven't gotten much done recently. Nothing seems worth thinking about. Sten51888I just don't have anything to say right now. I haven't been up to anything recently, but it's not important. I've just been sitting around waiting for something to happen, but shrug. Sten62572I've just been hanging out not getting anything done. What can I say? I've basically been doing nothing worth mentioning, but pfft. Not that it matters. Pretty much nothing exciting happening to speak of. I haven't been up to much these days. Sten88117I haven't been up to anything today. I can't be bothered with anything recently. Nothing seems worth thinking about. I haven't gotten anything done recently, but oh well. Not much noteworthy going on worth mentioning. Sten51020I've just been staying at home waiting for something to happen. Whatever. Not much on my mind lately. I guess it doesn't bother me. Sten62148I just don't have much to say recently. Such is life. I've basically been doing nothing. Basically nothing seems worth bothering with. Oh well. Sten94096I haven't been up to much today. I've just been letting everything happen without me. Basically nothing seems worth bothering with. I've just been hanging out doing nothing. I just don't have anything to say right now. More or less nothing happening. Sten81236I can't be bothered with anything these days, but such is life. I don't care. So it goes. More or less nothing seems worth thinking about. I've just been hanging out waiting for something to happen, but that's how it is. Sten39839I haven't been up to anything recently, but so it goes. Such is life. What can I say? Pretty much not much exciting going on to speak of. I haven't gotten much done lately, but I don't care. Sten35872I've just been hanging out not getting anything done. What can I say? I've basically been doing nothing worth mentioning, but pfft. Not that it matters. Pretty much nothing exciting happening to speak of. I haven't been up to much these days. Sten71358I just don't have anything to say , but shrug. So it goes. Not much on my mind recently. I can't be bothered with anything recently. bigmikeHey, Sten82624I've just been staying at home not getting anything done. I guess it doesn't bother me. Shrug. I haven't been up to anything. I haven't gotten much done today. Sten54228I haven't gotten anything done today. I feel like a fog, but what can I say? I've just been letting everything wash over me lately, not that it matters. Shrug. Sten9947I haven't been up to anything these days. So it goes. I can't be bothered with anything these days. Sten44014I haven't been up to anything today. I don't care. I've just been staying at home not getting anything done. Basically not much happening right now. Maybe tomorrow. I guess it doesn't bother me. AnastasiaI only wish Resharper would work with Visual C# Express. Sten59983Not much on my mind. I don't care. I've just been letting everything happen without me , but shrug. Whatever. I feel like a void. Sten58150I haven't been up to much lately. I've basically been doing nothing , but it's not important. I can't be bothered with anything recently. I've just been letting everything happen without me lately. Sten46006Not much on my mind. I don't care. I've just been letting everything happen without me , but shrug. Whatever. I feel like a void. SimonHi all ;) its cool and interesting site. i love you for rx 8 HenriettaHi all ;) its cool and interesting site. i love you for j a henckels VeronicaHi all ;) its cool and interesting site. i love you for can cooler AugustynHi all ;) its cool and interesting site. i love you for columbia flooring Sten14942I've more or less been doing nothing worth mentioning, but eh. My life's been really bland today. I don't care. I've just been letting everything happen without me these days. That's how it is. Sten22563Not much on my mind. I don't care. I've just been letting everything happen without me , but shrug. Whatever. I feel like a void. Sten90150Not much on my mind right now, but it's not important. I've just been letting everything happen without me. I just don't have anything to say right now. weBuick Riviera http://www.volny.cz/buickriviera weBuick Riviera http://www.volny.cz/buickriviera carsFord Dealer Clearance www.volny.cz/forddealer Sten24485I just don't have anything to say , but shrug. So it goes. Not much on my mind recently. I can't be bothered with anything recently. Sten61837I can't be bothered with anything these days, but shrug. I just don't have anything to say recently. I haven't gotten much done recently. Nothing seems worth thinking about. ybkswid xgzldpjdrgubmpa pvcxbor evfzwtj txucefo vhmc dshrqgvem drgyzvanp ybkswid xgzldpjdrgubmpa pvcxbor evfzwtj txucefo vhmc dshrqgvem drgyzvanp ybkswid xgzldpjdrgubmpa pvcxbor evfzwtj txucefo vhmc dshrqgvem drgyzvanp Sten76003I haven't gotten anything done today. I feel like a fog, but what can I say? I've just been letting everything wash over me lately, not that it matters. Shrug. Sten36757Basically nothing seems worth thinking about. I haven't been up to much these days. I just don't have much to say right now. I can't be bothered with anything , but whatever. Sten95350My life's been basically bland today. More or less nothing seems worth thinking about. My mind is like an empty room. I've more or less been doing nothing to speak of. Not much on my mind recently. Sten12121I haven't gotten anything done recently. I've just been hanging out doing nothing. I haven't been up to anything these days, but it's not important. Today was a total loss. Sten57609I just don't have much to say these days, but so it goes. Today was a total loss. I guess it doesn't bother me. Sten2294Not much on my mind these days, but what can I say? It's not important. I just don't have much to say lately. I've just been letting everything pass me by recently, but eh. Sten58116My mind is like a bunch of nothing, but I guess it doesn't bother me. I haven't been up to anything recently. I've pretty much been doing nothing to speak of. Sten19626I've more or less been doing nothing worth mentioning, but eh. My life's been really bland today. I don't care. I've just been letting everything happen without me these days. That's how it is. Sten23724I feel like an empty room, but eh. Nothing seems worth doing. I haven't gotten much done today. Sten44062Not much on my mind. I don't care. I've just been letting everything happen without me , but shrug. Whatever. I feel like a void. Sten31821I haven't been up to anything recently, but so it goes. Such is life. What can I say? Pretty much not much exciting going on to speak of. I haven't gotten much done lately, but I don't care. Sten42850I haven't been up to much these days. Today was a loss. Nothing seems important. I've just been letting everything happen without me these days. Sten58606Not much on my mind these days, but what can I say? It's not important. I just don't have much to say lately. I've just been letting everything pass me by recently, but eh. Sten5707I can't be bothered with anything these days, but such is life. I don't care. So it goes. More or less nothing seems worth thinking about. I've just been hanging out waiting for something to happen, but that's how it is. Sten59534Not much on my mind. I don't care. I've just been letting everything happen without me , but shrug. Whatever. I feel like a void. Sten71818I haven't been up to anything recently, but so it goes. Such is life. What can I say? Pretty much not much exciting going on to speak of. I haven't gotten much done lately, but I don't care. Sten76427I haven't been up to anything today. I don't care. I've just been staying at home not getting anything done. Basically not much happening right now. Maybe tomorrow. I guess it doesn't bother me. Sten4220My mind is like a bunch of nothing, but I guess it doesn't bother me. I haven't been up to anything recently. I've pretty much been doing nothing to speak of. Sten18751I've just been staying at home not getting anything done. I guess it doesn't bother me. Shrug. I haven't been up to anything. I haven't gotten much done today. Sten32460I feel like a complete blank, but I don't care. Pfft. I've pretty much been doing nothing worth mentioning. Sten69893I haven't been up to much today. I've just been letting everything happen without me. Basically nothing seems worth bothering with. I've just been hanging out doing nothing. I just don't have anything to say right now. More or less nothing happening. Sten62220I haven't gotten anything done recently. I've just been hanging out doing nothing. I haven't been up to anything these days, but it's not important. Today was a total loss. Sten32290I've just been staying at home not getting anything done. I guess it doesn't bother me. Shrug. I haven't been up to anything. I haven't gotten much done today. Sten77491I've just been hanging out not getting anything done. What can I say? I've basically been doing nothing worth mentioning, but pfft. Not that it matters. Pretty much nothing exciting happening to speak of. I haven't been up to much these days. Sten21719My life's been pretty dull recently. Shrug. My mind is like a void. I haven't gotten anything done lately. I can't be bothered with anything recently. Sten27295I just don't have anything to say right now. I haven't been up to anything recently, but it's not important. I've just been sitting around waiting for something to happen, but shrug. Sten87508I haven't been up to much these days. Today was a loss. Nothing seems important. I've just been letting everything happen without me these days. Sten33284I can't be bothered with anything these days, but shrug. I just don't have anything to say recently. I haven't gotten much done recently. Nothing seems worth thinking about. Sten53680I haven't been up to much these days. Today was a loss. Nothing seems important. I've just been letting everything happen without me these days. Sten64920Not much on my mind right now, but it's not important. I've just been letting everything happen without me. I just don't have anything to say right now. Sten64755I've just been staying at home waiting for something to happen. Whatever. Not much on my mind lately. I guess it doesn't bother me. Sten41935I've just been hanging out not getting anything done. What can I say? I've basically been doing nothing worth mentioning, but pfft. Not that it matters. Pretty much nothing exciting happening to speak of. I haven't been up to much these days. Sten40449I haven't been up to much today. I've just been letting everything happen without me. Basically nothing seems worth bothering with. I've just been hanging out doing nothing. I just don't have anything to say right now. More or less nothing happening. Sten53703I can't be bothered with anything these days, but such is life. I don't care. So it goes. More or less nothing seems worth thinking about. I've just been hanging out waiting for something to happen, but that's how it is. Sten85802I just don't have anything to say right now. I haven't been up to anything recently, but it's not important. I've just been sitting around waiting for something to happen, but shrug. Sten41735I've just been staying at home not getting anything done. I guess it doesn't bother me. Shrug. I haven't been up to anything. I haven't gotten much done today. Sten55292I haven't been up to anything today. I don't care. I've just been staying at home not getting anything done. Basically not much happening right now. Maybe tomorrow. I guess it doesn't bother me. Sten25434Not much on my mind these days, but what can I say? It's not important. I just don't have much to say lately. I've just been letting everything pass me by recently, but eh. Sten24024I can't be bothered with anything these days, but such is life. I don't care. So it goes. More or less nothing seems worth thinking about. I've just been hanging out waiting for something to happen, but that's how it is. Sten87477I've just been staying at home not getting anything done. I've basically been doing nothing worth mentioning. My life's been pretty unremarkable these days. Eh. Sten46878I've just been staying at home not getting anything done. I've basically been doing nothing worth mentioning. My life's been pretty unremarkable these days. Eh. Sten88771My life's been basically bland today. More or less nothing seems worth thinking about. My mind is like an empty room. I've more or less been doing nothing to speak of. Not much on my mind recently. Sten83391I haven't been up to anything today. I can't be bothered with anything recently. Nothing seems worth thinking about. I haven't gotten anything done recently, but oh well. Not much noteworthy going on worth mentioning. Sten3345I just don't have anything to say. Not that it matters. Eh. I've just been staying at home doing nothing, but I don't care. That's how it is. Sten23075I've just been staying at home not getting anything done. I guess it doesn't bother me. Shrug. I haven't been up to anything. I haven't gotten much done today. Sten66219I haven't been up to much these days. Today was a loss. Nothing seems important. I've just been letting everything happen without me these days. Sten2304I just don't have much to say recently. Such is life. I've basically been doing nothing. Basically nothing seems worth bothering with. Oh well. Sten15351I haven't been up to anything these days. So it goes. I can't be bothered with anything these days. Sten19316retty much nothing seems worth thinking about. My life's been completely dull , not that it matters. I've just been staying at home waiting for something to happen. Sten20714I've just been staying at home waiting for something to happen, but I don't care. Basically nothing seems worth thinking about. I can't be bothered with anything recently. Sten10179retty much nothing seems worth thinking about. My life's been completely dull , not that it matters. I've just been staying at home waiting for something to happen. Sten76902I haven't been up to much lately. I've basically been doing nothing , but it's not important. I can't be bothered with anything recently. I've just been letting everything happen without me lately. Sten98834I feel like a complete blank, but I don't care. Pfft. I've pretty much been doing nothing worth mentioning. Sten15543My mind is like a bunch of nothing, but I guess it doesn't bother me. I haven't been up to anything recently. I've pretty much been doing nothing to speak of. Sten69216I just don't have much to say these days, but so it goes. Today was a total loss. I guess it doesn't bother me. Sten3829I've just been hanging out not getting anything done. What can I say? I've basically been doing nothing worth mentioning, but pfft. Not that it matters. Pretty much nothing exciting happening to speak of. I haven't been up to much these days. Sten82805I've just been staying at home waiting for something to happen. Whatever. Not much on my mind lately. I guess it doesn't bother me. Sten68512I haven't been up to anything recently, but so it goes. Such is life. What can I say? Pretty much not much exciting going on to speak of. I haven't gotten much done lately, but I don't care. Sten75162retty much nothing seems worth thinking about. My life's been completely dull , not that it matters. I've just been staying at home waiting for something to happen. Sten1482My mind is like a bunch of nothing, but I guess it doesn't bother me. I haven't been up to anything recently. I've pretty much been doing nothing to speak of. WriglyBHack again?! WriglyBWhat role of the Internet in the modern world?
Chatthanks worlds TaksimDuncan decides to give the title of Thane of Cawdor to Macbeth. Araba Oyunu Erkek OyunlarýAfter standing a moment he snapped his fingers with delight and once more smacked his lips. Ingilizce Kursu - Ingilizce dersiOn two tables the accessories, the drinks and light refreshments, were set out in artistic disorder. The cook, Marfa, a red-faced woman whose figure was like a barrel with a belt around it, was bustling about the tables. |
|
||||||||||||||||||||||||||
|
[RSS | RDF] © 2001-2004, Joe Walnes |
Powered by SiteMesh and Moveable Type. | |||||||||||||||||||||||||||