[fpc-pascal] Lazarus and FPC integration

Agustin Barto abarto at gmail.com
Mon Oct 31 00:09:58 CET 2005

On 10/30/05, L505 <fpc505 at z505.com> wrote:
> > > I solved the problem using a single-rooted wrapper hierarchy (java
> > > style). It's not elegant nor efficient,
> Google.com
> Your search - "single-rooted wrapper hierarchy" - did not match any documents.

Let's say you need a general purpose list to store any kind of
primitive data or objects (you don't know in advance what are you
going to store). This problem can be solve with the good ole TList and
casting, but you have to deal with pointers and their syntax. What I
did is define an abstract wrapper (a class) that can be evaluated to
any primitive type or Object. I then define implementations of this
wrapper for the primitive types, and make a list of wrappers using
TList or TObjectList. If a wrapped is evaluated for the wrong type, I
throw an exception (Or I just let fpc/delphi deal with the call to an
abstract method).

As I said, it wasn't elegant nor efficient, but certainly was
flexible. Looking back (this code is from two years ago) I guess I
could have done things differently, but at the time I was just
starting with Pascal and I was in a rush to get my CS degree.

More information about the fpc-pascal mailing list