What I was referring to is that almost if not all building blocks to make this an official language feature are already there.
We have the way to create unnamed record types when declaring a variable like this:
var
x: record name: string; count: Integer end;
But we cannot do that for a return type (we get an E2029 Identifier expected but ‘RECORD’ found)
function Foo: record name: string; count: Integer end;
begin
end;
which would be a bit more verbose than its C# counterpart:
(string, int) Foo()
{
return ("Hello World", 42);
}
var foo = Foo();
Console.WriteLine(foo.Item1 + " " + foo.Item2);
C# uses the Tuple<string,int> type here which has these Item1… etc fields
I could have given the return type explicit field names though or directly deconstruct into local variables like this:
(var name, var count) = Foo();
Console.WriteLine(name + " " + count);
Now getting back to the verbosity if we had at least the Tuple deconstruction and some builtin Tuple types like .NET has (I think up to 20 or so fields - well personally 4 or so would be good enough, if you need more you can still write your own) you could write this:
function Foo: Tuple<string,Integer>;
and then use the aforementioned deconstruction (that would be the only missing piece currently and personally I think this should simply be done with a new operator overload) - given name and count are already declared (pre inline variables) - I have not decided of what the best syntax would be so I am using parantheses just like C# does which feels ok given we also use these when doing const record declaration:
(name, count) := Foo;
or use inline variables with type inference:
(var name, var count) := Foo;
Since you cannot overload on return type there should be no issue with type inference and possible overloads. Maybe I should really submit this as a feature proposal 