Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Language    [ Add a report in this area ]  
Report #:  59795   Status: Closed
Enum for in loop to support enumtype
Project:  Delphi Build #:  11.0.2627.5503
Version:    11.0 Submitted By:   Huzella Balázs
Report Type:  Suggestion / Enhancement Request Date Reported:  3/21/2008 6:14:10 AM
Severity:    Infrequently encountered problem Last Updated: 5/29/2009 1:31:05 PM
Platform:    All platforms Internal Tracking #:   258493
Resolution: Won't Do (Resolution Comments) Resolved in Build: : 12.0.3320.19366
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 1
Description
It would be great if 'for in do' loops could support enumeration type as a constant set.

This set could be implicitly created by the compiler to allow this type of enumeration.
Steps to Reproduce:
unit Unit1;

interface

implementation

type
  TEnum = (first, second, third);

function ProcessEnum: TEnum;
begin
  for Result in TEnum do
    Continue;
end;

end.


The compiler says:

[DCC Error] Unit1.pas(12): E2029 '(' expected but 'DO' found
[DCC Error] Unit1.pas(13): E2430 for-in statement cannot operate on collection type 'TEnum'
Workarounds
function ProcessEnum: TEnum;
begin
  for Result := Low(TEnum) to High(TEnum) do
    Continue;
end;


While this is flexible, the 'for in do' style is shorter and smarter.
Attachment
None
Comments

None

Server Response from: CODE1