Sven Barth wrote:

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...)

In that case how about

type TInteger2Tuple= tuple of (integer, integer);

var  i2: TInteger2Tuple;

begin
  i2 := TIntegerTuple(0);

for the very specific case where the tuple on the LHS is only allowed elements of a single type (or at the very least must be assignment-compatible with each other) and there is only a single element on the RHS.

Since under normal circumstances a tuple contains more than one element, this couldn't be confused with a cast.

--
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

Reply via email to