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

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


On 26.01.2013 21:09, Mark Morgan Lloyd wrote:
> Michael Van Canneyt wrote:
>> On Sat, 26 Jan 2013, 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".
>>>
>>> Please note the following points:
>>> * This is not the final specification for Tuples and thus open to
>>> discussion (there are still some issues with this draft that need to
>>> be solved)
>>> * I won't implement this feature myself (at least not in the near
>>> future) as I have other topics on my list (most importantly generics
>>> once type helpers are commited), so Alexander is free to give the
>>> task for implementation to his student.
>>
>> After a first read, looks OK. You seem to have thought of everything
>> that needs to be described, except maybe extraction of a single element:
>>
>> b : tuple of (integer, integer);
>> a : integer;
>>
>> begin
>>   b:=(1,2);
>>   a:=b[0]; // a = 1 after this.
>> end;
>
> Iff a tuple contains elements of the same type and if tuples with this
> restriction are compatible with arrays, wouldn't this behaviour be
> implicit?
>

The [] operator would then also be allowed for tuples with different types.
Also I'd make tuples only assignment compatible to arrays (thus you 
could not use the array's [] operator on a tuple). But it seems anyway 
that the extensions aren't favored that much...

Regards,
Sven



More information about the fpc-devel mailing list