Are duplicate operators legal?


Whilst debugging, I came across an erroneous line of the form...


iIndex := iVal + + 7;

(iIndex and iVal being properly defined Integers);


This surprised me as it did NOT cause a compiler error;

I seems that missing arguments between '+' and '-' operators do NOT cause a compiler error.

For example:

iIndex := iVal + - + + - 7;

Does not invoke a syntax error!

How can this be so? I suppose that as there is no argument then the parser can simply ignore the preceding operator but that seems a little cavalier? Or am I missing something?


Responses (1)
  • Accepted Answer

    Thursday, July 13 2017, 04:00 AM - #Permalink


    iIndex := iVal + (+7);     // You can also iIndex := iVal + (-7);



    The reply is currently minimized Show
Your Reply

Please login to post a reply.........