On 10/30/05, L505 <[EMAIL PROTECTED]> 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. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal