[fpc-pascal] Feature announcement: Dynamic array extensions

Maciej Izak hnb.code at gmail.com
Sun May 20 21:49:15 CEST 2018


2018-05-20 20:44 GMT+02:00 Sven Barth via fpc-pascal <
fpc-pascal at lists.freepascal.org>:

> Anthony Walter <sysrpl at gmail.com> schrieb am So., 20. Mai 2018, 19:09:
>
>> By the way, what's the reason for differences in () / [] syntax between
>> objpas and delphi mode?
>>
>
> For the non-Delphi modes I decided to keep consistency with static array
> constants (which use the same syntax in Delphi btw!). For the Delphi modes
> I followed what Delphi does. And for some reason the Delphi devs thought it
> better to use a different syntax than that for static arrays. 🤷‍♀️
>

Gratz, seems that I will need to update NewPascal soon to get this fresh
feature :).

They decide for [] probably because it is similar syntax like for open
arrays. IMO "[]" syntax has more dynamic meaning/nature so looks more
proper for this feature (as you said "()" syntax is used for static
arrays), but this is probably individual taste.

"[]" also might be better for something like this :

var
  f: array of TSomeRec = [(a: 10; b: ['1', '2']), (a: 20; b: ['6'])];

instead of

var
  f: array of TSomeRec = ((a: 10; b: ('1', '2')), (a: 20; b: ('6')));

The main gain of different syntax between Delphi and ObjFpc is more
troubles for Pascal Programmers. :(

Why you decide to prohibit static array constants inside dynamic array
constants for Delphi modes in r39045? I do not understand this decision. It
is some punishment for using Delphi mode? -,- IMO bad decision.

For the consequence the following code

var
  f: array of TSomeRec = [(a: 10; b: ['1', '2']), (a: 20; b: ['6'])];

should be also prohibited in Delphi mode, because it not works in Delphi
like static array constants inside dynamic array constants...

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180520/12461edc/attachment.html>


More information about the fpc-pascal mailing list