Archive for the ‘Anonymous Methods’ Category.
September 7, 2012, 1:02 pm
When you work with UIs, order of operations can be very important. Windows’s UI works based on an event queue and a message pump that reads events from the queue and dispatches them. And since the UI is single-threaded, this means that at any time, there could be pending events about to execute while you’re handling some UI code.
Sometimes you’ll get into a situation where you need to execute something, but not right away; you need it to happen after all of the pending events have processed. Now, obviously, the best way to make something happen after everything in the queue has processed is to put something else onto the queue directly behind everything that’s currently in there. But the tricky part is what happens when it comes back out. Continue reading ‘Delayed action’ »
November 21, 2010, 10:15 pm
October 28, 2009, 9:45 pm
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]
Continue reading ‘How to leak a class you never defined’ »
October 16, 2009, 12:22 am
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.
Continue reading ‘Under the hood of an anonymous method’ »
September 29, 2009, 5:23 pm
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?’ »