I find 
  viewTransform := TMat4.Identity;
  viewTransform := viewTransform  * TMat4.Translate(x, y, 1);
  viewTransform := viewTransform  * TMat4.Scale(scale, scale, 1);

much more readable.  

But I would just do:
  viewTransform := TMat4.Identity  * TMat4.Translate(x, y, 1) * 
TMat4.Scale(scale, scale, 1);

why bother storing the intermediate results at all?

Putting the operator before the = makes you have to go back and look to see 
what the operator is, where having the code in Result := Term * Term;  format 
is more readable because you read it left to right and the operators are in the 
correct order they are actually used.   I admit I am probably biased by looking 
at code without += for 35 years, but I still find it more readable.   I 
completely understand += -= *= and /= I just don't care for it from a 
readability point of view.. and figuring our what some code is doing 2 years 
from now is way more important than getting it to work right now... it's when 
you go back later you want it to be as readable as possible.  I guess I just 
prefer  Variable := Formula;  syntax and the clarity of it.

James 


-----Original Message-----
From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Ryan 
Joseph
Sent: Wednesday, August 14, 2019 2:58 PM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] += property bug?



> On Aug 14, 2019, at 2:53 PM, James Richters <ja...@productionautomation.net> 
> wrote:
> 
> I have only used  += once;  I normally would not use I:=I+1; or I+=1;   I 
> would use Inc(I);

Here’s an example of why we like c-style operators, i.e. it reduces redundancy 
of the variable name. It’s no surprise that programmesr figured out 
"viewTransform := viewTransform  *” could be compressed and still have the same 
meaning.

  viewTransform := TMat4.Identity;
  viewTransform *= TMat4.Translate(x, y, 1);
  viewTransform *= TMat4.Scale(scale, scale, 1);

        or

  viewTransform := TMat4.Identity;
  viewTransform := viewTransform  * TMat4.Translate(x, y, 1);
  viewTransform := viewTransform  * TMat4.Scale(scale, scale, 1);

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to