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

Alexander Klenin klenin at gmail.com
Sun Jan 27 20:16:35 CET 2013


On Mon, Jan 28, 2013 at 4:19 AM, Michael Van Canneyt
<michael at freepascal.org> wrote:
> Define an iterator type/operator.
>
> - No interface
> - No 'specially named function' in the class. The iterator should be
> separate from the class.
> Now they promoted 1 function with a special name to a special status:
> 'GetEnumerator'

Ah, you mean that FPC's "operator Enumerator" is better?
I agree, but the difference is not too great.

> All identifiers should be equal for the law :-)
I know only two languages with such extreme disdain for reserved words:
Forth and, to a lesser extent, Lisp.
For example, in Forth, a comment (!) is not a built-in construct,
but a word (Forth's analog of procedure) defined in standard library.


> Which begs the question why you didn't use a record to begin with.
>
> I still do not see why the enumerator could not simply return a record
> record
>   key : tkey;
>   value : tactualtype
> end;
>
> for r in myclass do
>   begin
>   Writeln(r.key);
>   With r.value do
>   end.

the point of my tuples proposal is to do exactly that, with only a
single change --
allow to *also* write loop as
for key, value in myclass do
   begin
   Writeln(key);
   with value do
   end;

while keeping enumerator the same.

> Borland did a world of good for (Object) Pascal, up to Delphi 7.
> After that, it went seriously downhill in my opinion; Adding randomly
> features without clear direction or regard for the
> intent and philosophy of the Pascal language - or so it seems to me.
> Like a ship at the mercy of the waves...
I would rephrase slightly -- the features they added are, in
principle, good ones.
However, they hastily (and randomly?) copied them from other languages without a
proper adaptation.
Take, for example, recently added to FPC array constructors:
TIntegerDynArray.Create(1, 2, 3) is much too noisy, and inconsistent
with other syntax
(it resembles a standard constructor, but takes variable-length
argument list, which is impossible for standard constructors).
So I would much prefer
TIntegerDynArray(1, 2, 3), TIntegerDynArray([1, 2, 3]), or maybe even
just [1, 2, 3] if appropriate automatic conversions are defined.

--
Alexander S. Klenin



More information about the fpc-devel mailing list