March 15, 2010, 4:07 pm
Delphi 2010’s help describes TValue, used by the RTTI unit to store values of arbitrary types, as “a lightweight version of the Variant type.” I saw that and it made me wonder, how lightweight is it? How fast is using TValue?
Thankfully, among D2010’s lesser-known new features is the Diagnostics unit, which gives us TStopwatch, a simple record for timing operations. That makes it very easy to write a simple speed test.
Continue reading ‘TValue is very slow!’ »
March 9, 2010, 2:41 pm
I really loved when Delphi 2009 came out, how it fixed so many ugly problems in the Delphi IDE. The stability issues and memory leaks that plagued D2006 and D2007 were greatly reduced. And it just got better in D2010.
The tradeoff, though, seems to have been compiler stability. Trying to do anything with Generics in D2009 before Update 3 came out was a nightmare, and even after, (and even in D2010,) there were still plenty of dark corners where you can end up with an Internal Compiler Error or linker error on something that, syntactically speaking at least, is perfectly cromulent Object Pascal.
Continue reading ‘How to break the D2010 compiler’ »
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 20, 2009, 10:22 am
Last week at work, I was asked to look at one of our verification modules that was taking about three times longer to run than it had in an earlier version. This module takes a set of result files, compares them against another file showing expected results, and reports any discrepancies that are outside the defined margin of error. It’s some pretty heavy work involving hundreds of thousands of data points, and the old version already took more than ten minutes. Increasing the running time by a factor of three just wasn’t acceptable. So I started to look at what was going on.
Continue reading ‘Real-world optimization’ »
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’ »
October 6, 2009, 9:46 pm
On TVTropes, one of my favorite websites, there’s a phrase that’s only invoked when an author writes about something real, but uses it in a way that’s impossible and completely contrary to its nature: “X does not work that way.” For example, if a sci-fi show features space fighters dogfighting and making turns that would only be possible with atmospheric friction against the hull, or gradually drifting to a stop if the engines stop thrusting, that might get listed under “Space does not work that way.”
What does this have to do with Delphi programming? Bear with me. Continue reading ‘Asking the impossible’ »
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?’ »
September 23, 2009, 2:06 pm
NOTE: The download link in the original version of this post got mangled by WordPress. It’s been corrected now.
A couple weeks ago, I gave a presentation at the CodeRage 4 online conference about dynamic class creation at runtime in Delphi. The replays were just posted yesterday at Embarcadero’s CodeRage site. Continue reading ‘Dynamic class creation’ »