Sven Barth wrote:
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...
Cautionary tale follows, slightly OT. I don't know whether you've ever
looked at APL but given an array X you can either select an element
X[1,2] or you can specify the significant axis [2]X Somebody tried to
write a parser using YACC and found this was ambiguous, they ended up
having to recognise one of the cases in the lexer and (in effect) change
the brackets into something else. Fun language: you can parse it
left-to-right but have to remember that it executes right-to-left.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel