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

Michael Van Canneyt michael at freepascal.org
Sat Jan 26 20:14:11 CET 2013



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;

In this sense, it seems more like an array of const than as a record.

I would not do the extensions. The tuple is simply a logical, immutable grouping of values.
I would also not allow operators other than := <> and =, because in expressions,
when encountering a (, it is not clear what is meant.

Stick to what can be considered well-defined.

Michael.



More information about the fpc-devel mailing list