Posts tagged ‘Delphi’

Generics and the Covariance Problem

Since some version of this question keeps showing up on StackOverflow, and the answer’s always basically the same, I figured I may as well write up a post on here that people can link to.  Here’s the question, in simplified form:

“Why can’t I pass a TList<TMyDerivedObject> to a function that’s expecting a TList<TMyBaseObject>?  You can pass a TMyDerivedObject to a parameter expecting TMyBaseObject, so why doesn’t it work for lists?”

Continue reading ‘Generics and the Covariance Problem’ »

Inheritance baggage

A couple posts ago, I mentioned that I’ve been working with code generation lately.  This is for a part of the TURBU project.  An RPG relies pretty heavily on scripting, and RPG Maker, the system I created TURBU to replace, has a fairly extensive, if limited, scripting system.  The limitations were one of the things that made me say “I could do better than this,” in fact:  No functions, no local variables, callable procedures exist but parameters don’t, so any “passing” has to be done in global variables, only two data types: integer and boolean, no event handlers, minimal looping support, etc.

Continue reading ‘Inheritance baggage’ »

AnyDAC: First impressions

Over the last few days, when I’ve had some free time available, I’ve been working with AnyDAC’s TADMemTable, which Dimitry Arafiev, the author, pitched to me as a replacement for and an improvement upon TClientDataset. I’d like to report on how smoothly everything went and how well it works, and spend some time on my experience with the dataset and the new features it brings to the table.

Unfortunately, I don’t always get what I’d like.  I can’t really talk about stuff like that because I haven’t reached that point yet, due to various bugs and other implementation hurdles.

Continue reading ‘AnyDAC: First impressions’ »

I think I just got sponsored

A couple days ago, I got an email from a member of the AnyDAC dev team.  They make a set of professional data-access components for Delphi, and they’re looking for feedback and publicity.  They were willing to give me a free license, worth about $400, if I’d take the time to evaluate their components, provide some feedback and suggestions, and write up a few reviews on here.  Apparently they’re particularly interested in getting some focus on their in-memory dataset, DatS, which isn’t documented particularly well and doesn’t get used much. Continue reading ‘I think I just got sponsored’ »

Going to DelphiLive! again.

This time last year, I was getting ready to take a plane down to California to attend the DelphiLive! conference, where I’d been invited to speak about developing games in Delphi.  This year, it’s been pushed back a few months, to be held in late August instead of mid-May, and I just now got the acceptance email from the organizers.  Looks like I’ll be presenting two sessions this year: “Using extended RTTI to make your life easier,” and “Game engine development in Delphi.”

Continue reading ‘Going to DelphiLive! again.’ »

Adding non-data fields to a client dataset

A lot of the UI design for the TURBU editor is based on data-aware controls bound to client datasets.  I was trying to build a new form this morning that required me to filter one of the datasets.  Problem is, that would break other things that expected it not to be filtered.  Well, that’s not such a big problem, because TClientDataset has an awesome method called CloneCursor that lets you set up a second client dataset that shares the first one’s data store, but with independent view settings.  So I used a cloned dataset, and immediately got an exception when I tried to run.  The control I was using couldn’t find the field.

Continue reading ‘Adding non-data fields to a client dataset’ »

Personal property and computing

I’ve always been a big fan of Apple’s.  My first computer was an Apple IIe, and finding a copy of BASIC on there was what first got me into programming.  A good percentage of the modern user interface concepts we take for granted today were invented by Apple back in the 1980s.  (Yes, I know, they got the basic concepts from Xeroc PARC, but a lot of their work was their work, not Xerox’s.)  They’ve always been one of the major drivers of innovation in the computer industry, and they’ve done a lot to hold the line against Microsoft’s campaign for complete domination of the computer industry.  They’re one of a very few companies that have actually had any real success in that area, and we all owe them a debt of gratitude for that, if nothing else.

Apple released the latest iPhone development license yesterday, and I suddenly find myself a lot less grateful.

Continue reading ‘Personal property and computing’ »

The joys of old code

I’ve been playing around with Delphi ever since high school.  I took a Pascal programming class and thought it was a really cool language.  Shame you couldn’t do visual programming with it, though.  (I was really into VB at the time.)  Then a buddy of mine introduced me to version 1 of “this new Visual Pascal program” and it was love at first byte.  But I didn’t get real serious about Delphi until about three years ago, when I decided to dust off an old pet project of mine from the D7 days, a tool I created for the purpose of making team collaboration easier for RPG Maker 2000 projects.

Continue reading ‘The joys of old code’ »

Delphi memory management made simple

Most of my posts on here have been about technical subjects, geared towards moderate-to-advanced Delphi coders.  This one’s to help out the beginners who are still learning the ropes.  I’d like it to be something that people can send new users to from StackOverflow or other sites if they’re having trouble figuring out how to clean up their memory properly.

I’ve never really understood why people find memory management difficult.  Maybe I just “get it” for some reason, but it’s never seemed all that arcane or complex to me.  In all my time working with Delphi, I’ve only run into one truly difficult memory management scenario, and it’s something that most people won’t ever have to deal with: sharing global interface references across package boundaries.  If you do that wrong, you’re likely to run into some very strange errors at program shutdown that are hard to debug.

But people keep asking questions about the basics of what to free and how to free it on StackOverflow, and from answering them and analyzing the questions and the answers, it seems to me that the entirety of memory management can be boiled down to one single principle.

Continue reading ‘Delphi memory management made simple’ »

Closing the documentation gap

This morning on StackOverflow, someone asked a question about invoking constructors through extended RTTI. It happened that I’d had to work out a way to do that a couple weeks ago, and it took me about 5 minutes to find the code, strip out a few specific details and type up a solution.  I got an accepted response, a few upvotes, and a very interesting comment from the author:

Continue reading ‘Closing the documentation gap’ »