[fpc-pascal] Feature proposal: function-based assignment operators

Jürgen Hestermann juergen.hestermann at gmx.de
Thu Mar 28 18:26:24 CET 2013


Benito van der Zander wrote:
>> array1[array2[i]] := min(array1[array2[i]], 42);
>> Now, you need to repeat all the array indices.
>> Which is very ugly.
>> So there should be an alternative syntax, similar to += :
>> I.e.:
>>    array1[array2[i]] min= 42;

Now *that* is ugly. It would take me quite a while to find out what happens here.
What is assigned to what and when?
Why making Pascal look like C instead of using C?
In the example case I would prefer the original or write

if array1[array2[i]]>42 then
     array1[array2[i]] := 42;

or if performance is realy an issue you I would use an intermediate pointer to the array type:

var p : ^arrayelementtype;

p := @array1[array2[i]];
p^ := min(p^,42);



More information about the fpc-pascal mailing list