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

Benito van der Zander benito at benibela.de
Thu Mar 28 16:23:14 CET 2013


Hi,
quite often you need to change a value relatively to another value.
For example:

   array1[array2[i]] := array1[array2[i]] + 42;

Luckily this can be written as

   array1[array2[i]] += 42;

Which is nice.

However, sometimes you do not need addition, but the minimum.
For example:

    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;


More generally, if func is a 2-ary function, of type type(a) => type(b) 
=> type(a), the syntax

a func= b

should become a := func(a, b)

(Or alternatively the syntax   a : func = b;  might be easier to parse)


Benito




More information about the fpc-pascal mailing list