Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6788473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:29:24+00:00 2026-05-26T17:29:24+00:00

When working with lists of items where the lists just serve as a temporary

  • 0

When working with lists of items where the lists just serve as a temporary container – which list types would you recommend me to use?

I

  • don’t want to destroy the list manually
  • would like to use a built-in list type (no frameworks, libraries, …)
  • want generics

Something which would make this possible without causing leaks:

function GetListWithItems: ISomeList;
begin
  Result := TSomeList.Create;
  // add items to list
end;

var
  Item: TSomeType;
begin
  for Item in GetListWithItems do
  begin
    // do something
  end;
end;

What options do I have? This is about Delphi 2009 but for the sake of knowledge please also mention if there is something new in this regard in 2010+.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:29:25+00:00Added an answer on May 26, 2026 at 5:29 pm

    The standard list classes, like TList, TObjectList, TInterfaceList, etc, do not implement automated lifecycles, so you have to free them manually when you are done using them. If you want a list class that is accessible via an interface, you have to implement that yourself, eg:

    type
      IListIntf = interface
        ...
      end;
    
      TListImpl = class(TInterfacedObject, IListIntf)
      private
        FList: TList;
        ...
      public
        constructor Create; override;
        destructor Destroy; override;
        ...
      end;
    
    constructor TListImpl.Create;
    begin
      inherited;
      FList := TList.Create;
    end;
    
    destructor TListImpl.Destroy;
    begin
      FList.Free;
      inherited;
    end;
    
    function GetListWithItems: IListIntf;
    begin
      Result := TListImpl.Create;
      // add items to list
    end;   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working in C# win forms, I'm trying to create a list of items where
I am currently working on a website which lists the businesses as per either
I'm working with a list whose items are both selectable (using checkboxes) and sortable
In the project I'm working on I have got a list List<Item> with objects
This question has spawned out of this one. Working with lists of structs in
I'm working with a code base where lists need to be frequently searched for
I am working on a site that lists a directory of various restaurants, and
I'm working on an application that lists a stored library using a ListActivity. My
I am working on a WordPress site where one of the pages lists excerpts
I'm working with a demo of two sortable jquery lists... but have a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.