Mega Search
23.2 Million


Sign Up

Make a donation  
Are local classes going to be allowed?  
News Group: embarcadero.public.delphi.oodesign

Hi,

I just innocently included a class in function I was writing and was told off by the compiler when I went to run it:

{code}
function CalcCsvDelimiter(lines: TStrings): char;
type
  TDelimData = class
    delim: char;           
    counts: TArray;
    variance: double;       
  end;
var
   delims: TObjectList;
  ...
{code}

Local classes are possible in Apple's new language Swift. i can see that Delphi's split syntax, which generally I like, makes it harder to have a convenient way to add methods to a local class. In this case it was pure data, and I wanted the convenience of a generic TObjectList.

But surely there is a way to add this control of scope to Delphi. Has Embarcadero thought about this?

Regards
Mark

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 13-Sep-2014, at 8:55 PM EST
From: Mark Patterson