Talk:Short-circuit evaluation: Difference between revisions
→Compiler optimisations?
Line 94:
I still think the lead sentence, speaking of avoiding lengthy calculation, should mention not just (''quick'' or ''slow'') but also (''safe'' and ''test'') as justification for knowing just what will happen. I don't regard avoiding an array indexing error as a side effect. If it is avoided, it doesn't happen. [[User:Dinosaur|Dinosaur]] ([[User talk:Dinosaur|talk]]) 11:28, 6 May 2015 (UTC)
:
::Ahem. I've done that too, and with intent. The IBM1620's Fortran II compiler allowed only simple expressions for array indexing, (''const''*''variable'' +- ''constant'') and I wanted (I + J) inside a READ statement's list and there was some reason why I couldn't use an implicit DO-loop as in (A(K),K = I + J,...) or similar - possibly because that was a facility introduced in Fortran IV. Anyway, as you will have guessed, I found I could write A(J + 12345) after calling subroutine ZAP(12345,I) and suddenly, the storage set aside to hold the constant would contain ... something else. Naturally, there must be no other usage of a constant 12345 that expects it to have that value. On the IBM1130 this would ''not'' work, because although the constant would be damaged, constant offsets in array indexing were merged with the base address of the array and so vanished at run time. But array indexing now allowed arbitrary expressions.
|