Beware using anonymous methods in loops
Quick, what’s the output of this simple routine?
Continue reading ‘Beware using anonymous methods in loops’ »
Mason Wheeler's thoughts on Delphi programming in general, and particularly on the technical aspects of developing the TURBU engine and editor.
Posts tagged ‘Anonymous Methods’
Quick, what’s the output of this simple routine?
Continue reading ‘Beware using anonymous methods in loops’ »
Quick, what’s wrong with this code?
[code lang="delphi"] procedure ContrivedExample; var factorial: TFunc; begin factorial := function(input: Integer): integer begin if (input = 0) or (input = 1) then result := input else result := input * (factorial(input - 1)); end; writeln(factorial(5)); end; [/code]
I woke up this morning and checked DelphiFeeds, and found a very interesting post by Jolyon Smith about the use of the absolute keyword. That reminded me that I had to go and write up this article. Why? Because it’s the only way I know of to get inside an anonymous method’s functor object and do some looking around.
When I first saw the announcements for the new Delphi 2009 features, a little more than a year ago, my reactions went something like this:
Unicode: Hmm… looks interesting.
Generics: YES! FINALLY!
Anonymous methods: …huh?
I think that’s pretty much how everyone reacted to anonymous methods at first. Continue reading ‘What’s in a name-less method?’ »