[fpc-devel] RFC: Support for new type "tuple" v0.1

Sven Barth pascaldragon at googlemail.com
Sat Jan 26 20:26:18 CET 2013


On 26.01.2013 20:13, Mark Morgan Lloyd wrote:
> Sven Barth wrote:
>> Hello together!
>>
>> Based on the results of the "for-in-index" thread I've decided to come
>> up with a draft for the Tuple type which is thought by many people to
>> be a better alternative to "for-in-index".
>
> Nice, but I've got reservations about making tuples compatible with
> dynamic arrays (or at least, any more compatible than a dynamic array is
> with a normal array).

Which is why I added it under "extensions".

>
> I also note Alexander's earlier
>
>  >   ZEROES: array [1..10] of Integer = (0, 0, ..., 0);
>  > ...
>  > (x, y, z) := Tuple(ZEROES);
>
> which I'm afraid I really don't like since that sort of thing is too
> easily misinterpreted as making the language indeterminate.

Which is in turn why I required that the count of elements is the same...

> I'd vote for
> having implicit compatibility between a single element and a tuple i.e.
> something like
>
>  > (x, y, z) := Tuple(0);
>
> provided that x, y and z are all the same type. Granted that the same
> effect can be had by overlaying the assignment operator but this would
> save having to use per-element assignment or an intermediate array.
>

I don't know... this is again the "the right side is evaluated without 
knowing the left side" problem. Thus it is not known what types 
"Tuple(0)" should return. (Note: this "problem" does not apply to group 
assignments as proposed, because if necessary every value could just be 
copied to the stack and then retrieved (of course the compiler will 
optimize here...)

Regards,
Sven



More information about the fpc-devel mailing list