The feature I'd most like to see in Delphi is....

New Generic List Syntax for parameters

Currently we have open array parameters that simply place items within square brackets - simple, readable, fast. It would be nice to have syntax to do the same with generic collections. Obviously this would only be available once ARC has been implemented across all of Delphi.

the syntax I propose is in the third parameter of the function call below:

MyCall(Arg1, Arg2, TList<['AB', 'CD', 'EF']>);

The simplest type that applies to everything in the open array of the above example is string, so the equivalent longhand for the TList constructor would be:

with TList<string>.Create do
for value in TStringDynArray.Create(['A', 'B', 'C']) do
Add(value);

Since the the open array generic constructor is by definition defined at compile time the compiler should be able to identify the type of each element of the open array either because it is a variable of a given type, or by the same method it uses for constants currently. Then all that would be required is some simple rules for combining disparate types (which already exist for most situations):
* floating types expand to the largest required type of float,
* Integers become floats when combined with floats
* Chars become strings when combined with strings
* Mixing across simple types e.g. string and integer could make them all into variants
* Structure types must be name compatible or a compile error is raised

2 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Scott shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base