Alexander Klenin schrieb:
I think you meant "array of const" instead of "open array", since open array is
just a method to pass arbitrary-sized array (of a single element type,
of course).
Yes, indeed. I missed that you already mentioned "array of const" as a
possible syntax/implementation.
As for array of Vaiant and array of const -- they are very different
from the tuples proposal.
Note that tuples proposal is carefully constructed in such a way that
tuples are statically (but implicitly)
typed, so no run-time overhead is involved, and all type errors are
detected at compile-time.
I doubt that this is possible in OPL without much additional (type,
name) information in source code. Consider how many number types exist,
so that "[1]" can be a 1-tuple of almost any numeric type. Depending on
what exact type the compiler chooses, the type may be too big or too
small for subsequent assignments of other values, or to records. A
practical implementation IMO will ressemble a record definition with
explicit types added to every element. Otherwise "array of const" could
be used, with included type information, and (automatic) type conversion
when a tuple is used as a parameter list or operand.
The use as an argument list replacement will hardly match the signature
of the subroutine, which expects exact types, modifiers (const/var) and
calling convention (register/stack usage).
I don't see how tuples can be used without a new variable type. Without
such an container the assignment of one tuple to another one will have
no useful effect, because the result is lost.
Can you give more practical examples on your idea of using tuples in OPL?
I only could find an obvious use in record constructors, where the
target record provides the tuple type as in
ARectangle.TopLeft := (100; 200);
or better
ARectangle.TopLeft := [100, 200];
This would be nice, indeed, but hardly worth to introduce tuples for
only this purpose.
DoDi
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel