Benito van der Zander wrote:
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;

Declare a custom function and mark it inline for efficiency. That also allows you to document it properly, have different implementations depending on the parameter types and so on.

There really are limits to the extent that the underlying Pascal should be mangled further. Your time would be better spent trying to persuade the core developers to tolerate extra operators like ⌊ for floor(), and then working out how to implement them >:-)

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

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to