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

Michael Van Canneyt michael at freepascal.org
Sun Jan 27 13:29:31 CET 2013



On Sun, 27 Jan 2013, Alexander Klenin wrote:

> On Sun, Jan 27, 2013 at 10:10 PM, Michael Van Canneyt
> <michael at freepascal.org> wrote:
>>> 2.1) Tuples are always temporary and anonymous. You can not store a
>>> tuple, define tuple type, of variable of tuple type.
>>>  So tuples are 100% static, compile-time feature -- no change to
>>> RTTI, variants etc.
>> No.
>>
>> I think that tuples should be a full fledged type, not an anonymous one with
>> all the restrictions that come from it.
>
> 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.


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

I think that Sven (or Oxygen, they apparenly have it too) has more 
succeeded in preserving the essence of Pascal than your proposal does.

Sven's proposal is the least invasive in terms of concepts and whatnot.
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.

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.

>
>> Pascal is declarative.
> No, it is not.
> http://www.britannica.com/EBchecked/topic/417798/declarative-language
> http://en.wikipedia.org/wiki/Declarative_programming
>
> I think you meant that in Pascal identifiers must be declared before
> usage -- that is true,
> and of course tuples proposal agrees with that.

My apologies for the mixup in terminology, the latter is what I meant.

But the latter is why I think Sven's proposal (or the Oxygen implementation)
is more appropriate than yours:
- No messing with syntax, just a new type.
- Ability to declare a named type (not anonymous).

Michael.



More information about the fpc-devel mailing list