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

Benito van der Zander benito at benibela.de
Thu Mar 28 18:39:11 CET 2013


> Now *that* is ugly. It would take me quite a while to find out what 
> happens here.

Perhaps :min= was better?

> Why making Pascal look like C instead of using C?

C also does not support this :(

And it does not have arbitrary array index ranges

>
> In the example case I would prefer the original or write 
In the real program I ended up with

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

Then you have everything twice.

And if you have to change i to j, you might forget to change one


On 03/28/2013 06:26 PM, Jürgen Hestermann wrote:
> 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);
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list