[fpc-devel] Proposal: Enhanced replacement for assignment operators

Alexander Klenin klenin at gmail.com
Fri Aug 6 18:38:23 CEST 2010


On Sat, Aug 7, 2010 at 03:10, "Vinzent Höfler"
<JeLlyFish.software at gmx.net> wrote:
>> You don't have to spend time realizing that it's the same variable (not
>> e.g. SomeReallyLongVariableNameY) if you read the 1st form.
>
> But you can mistake the "+=" for a ":=". Replacing one possible reading error with another isn't much of an improvement.

You can also mistake "." for ",", ">=" for "<=", or mix up "<>", "><",
"<<" and ">>" --
which are all valid but different symbols in FPC. This is quite a minor problem.

Code bloat/duplication is much more serious.
It is usually not just SomeReallyLongVariableNameY, but something like:
SomeFunctionReturningObject(param1, param2).PointArrayField[i] +=
FunctionReturningPointOffset(param);
Try rewriting that without "+=".

> Maybe if you've learned reading Cish books, the former version is easier to read, but the books I learned reading with contained text. ;)

I have actually learned reading PL/I books, which is much worse ;-)

> But well, while we're at it, what about conditional expressions?
>
> X := (if A then Y else Z);
>
> (See <http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai05s/ai05-0147-1.txt> This is an Ada 2012 feature which I actually don't like at all for the same reasons as the C-like operators: they interrupt the normal flow of reading. But well...)

That is half-covered by IfThen family of functions.

-- 
Alexander S. Klenin



More information about the fpc-devel mailing list