2
votes
Vote UpVote

Weird code snippet #2: Generic Double Linked List

Lars Fosdal – They say Generics and pointers don't mix. type PMyThing<T> = ^TMyThing<T> // [DCC Error] E2508 type parameters not allowed on this type TMyThing<T> = record Thing: T; end;Ok, they don't. But there is a loophole!type TMyThing<T> = record Thing: T; NextThing: ^TMyThing<T>; end;Why this is allowed, I don't know. Just like I don't really understand why the first one is forbidden. There is probably some good explanation for it.Still - it can be fun breaking the rules!unit GenericDoubleLinkedList;interfaceuses Classes, Generics.Defaults;type ...
Favorite? Off-Topic? Lars Fosdal @ 2011-07-14 16:17

Statistics

Visits: 663
Votes: 2
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Alister Christie
Charles Ardour
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)