On Fri, 23 Apr 2010 08:17:21 -0400 Doug Chamberlin <dougchamber...@earthlink.net> wrote:
> On 4/23/2010 3:33 AM, spir ☣ wrote: > > Say I want to implement a kind of linked list which node data may be > > anything. Thus I cannot store data on place (in nodes), indeed; so it > > should be referenced. But pointers themselves are supposed to be typed. So, > > how can I do that? > > > > The key to solving this problem is to answer the question "How will I > know what type of data that pointer points to?" Once you determine what > is being pointed to you can cast Pointer^ to that type and all should work. > > I would use Pointer as an untyped pointer to anything and ignore the > warning. Perhaps you can turn off that warning for this code segment > since you are doing this intentionally. Thank you for both answers. Are there kinds of untyped data structures in the library (such as sequence/list, table/mapping/hash/dictionary). I'd like to see how they're implemented. As a detail, my need is not necessarily the collection to be untyped, but the type to be known and/or specified at runtime. So, it is closer to what is sometimes called "generics". I want to implement the container algorithms once only, since they don't depend on the type of the content. Then I may specialise eg a Sequence type into one for strings to add a join method. Denis ________________________________ vit esse estrany ☣ spir.wikidot.com _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal