Head over and download the Generics.Tuples unit from Github and start using it in your projects.
While it’s nice work (and raises questions about why EMBT itself isn’t showing this kind of initiative with the language, I’m not really sure how useful it is without more native support and some other features. Is it garbage-collected? By needing to reference “Value1” in your code example, does that mean it can’t be accessed by index like tuples in other languages? What about iterating through the values? It looks like the only way to assign multiple values at once is through the create method… unless there’s another method to assign multiple values again?
and the returned tuple would be unpacked into the two variables firstName and lastName.
>A sample usage for a tuple that he gives is being able to return two values from a function instead of just one.
We can do that now with records. The real use comes in the automatic unpacking and the arbitrary types. Needing to declare a generic-infused tuple beforehand, without even the benefit of type inference, and no unpacking doesn’t really gain anything.
The limitations of generics are also shown in that one is going to need to manually create versions of this tuple that work for each specific number of parameters.
I agree it basically would let you skip defining a record type at the top of the file (for up to 8 properties if 8 were defined). In your example you could just do SomeFunc(firstName, lastName, whatever); in Delphi. Less intuitive than assigning them with a := though.