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

Alexander Klenin klenin at gmail.com
Sun Jan 27 14:48:44 CET 2013


On Sun, Jan 27, 2013 at 11:29 PM, Michael Van Canneyt
<michael at freepascal.org> wrote:
>>
>> Let me restate:
>> 1) Tuple as a type does nothing new compared to a record, except for
>> possibility to omit field names.
> That's all we need.
I disagree. In fact, the ability to omit field names is, in my opinion,
the least valuable part of the concept.

>> 2) While I agree that omitting field names might be a useful shortcut,
>> it is wasteful to introduce a whole new
>>  keyword and syntax just for that -- I propose to just extend record
>> syntax, possible variants:
>>  type TKeyValue = record (Integer, String) end;
>>  type TKeyValue = record of Integer, String end;
>>  type TKeyValue = record Integer; String end;
>>  type TKeyValue = (Integer; String);
>> 3) The main part of the feature, IMHO, is a new tools for record and
>> array manipulation -- construction and deconstruction of tuples.
>>  So in my proposal, tuple is not a type, but a concept underlying a
>> syntax construct -- similar to, for example,
>>  a sequence of statements, or a parameter list.

> That is exactly what I want to avoid; messing with syntax.
Why do you think that using "record" keywork insteaf of "tuple" is more messy?
Yet, again, as with brackets -- while I think intruducing new type is
useless, and clutters the language,
it is also not harmful, so if the rest of the proposal gets implemented
(i.e. record and array construction/deconstruction), then I can easily
concede this point also.

> I think that Sven (or Oxygen, they apparenly have it too) has more succeeded
> in preserving the essence of Pascal than your proposal does.
This may or may not be true, depending on the definition of "essence".
However, note that I propose *smaller* amount of new concepts
(i.e. I propose new syntax element, while he proposed new syntax
element and a new type).
I also propose to allow using newly introduced concept in more places --
in my opinion, this is in agreement with orthogonality principle,
which you may, or may not consider part of the "essence" of Pascal.
I'd like to repeat again that I do not at all wish my proposal to be rejected
because I proposed to little -- so I agree to include tuple type if you want :)

> It is simply a new type, and besides solving your original problem, it has
> additional advantages: I see Python has it too, so it gives you ammunition
> in that discussion too.
Yes, but Python does not have records, so it does not suffer from
problem of record/tuple duplication.
Note also that tuple type does not in any way helps in for-in-index case.
The part that helps is tuple deconstruction syntax, which is
independent from whether the right part is tuple or record.

> I do not wish to reuse the record keyword, because the record syntax is
> already messy as it is with the variant parts.
> The TKeyValue = (Integer; String); is too reminiscent of an enumerated.
> The only thing that differentiates it is the use of type names. At the level
> of a parser, you have no way to decide what you are parsing without knowing
> what the symbols are.

Well, this part I can concede too -- this is a matter of taste,
and while I, by definition, think that my taste is best of all,
I'm quite aware that others may disagree with that :)
I'd just like to restate that, IMO, not much is gained by writing

TKeyValye = tuple (String, Integer); // Sven's variant
vs
TKeyValue = record key: String; value: Integer; end; // my variant

if the rest of the code is identical in both proposals.

--
Alexander S. Klenin



More information about the fpc-devel mailing list