Talk:Short-circuit evaluation: Difference between revisions

Content added Content deleted
Line 84: Line 84:
::::Notice that "and then" and "or else" are part of the Ada and Pascal standards. (the extended Pascal flavor, or ISO 10206, of course not the nonstandard Borland dialects) It would arguably be nice if short-circuit was the default. Likewise, it would be nice if statements like "integer n = 0" in a function were executed at each function call. But Fortran is not C. :) [[User:Arbautjc|Arbautjc]] ([[User talk:Arbautjc|talk]]) 19:17, 4 May 2015 (UTC)
::::Notice that "and then" and "or else" are part of the Ada and Pascal standards. (the extended Pascal flavor, or ISO 10206, of course not the nonstandard Borland dialects) It would arguably be nice if short-circuit was the default. Likewise, it would be nice if statements like "integer n = 0" in a function were executed at each function call. But Fortran is not C. :) [[User:Arbautjc|Arbautjc]] ([[User talk:Arbautjc|talk]]) 19:17, 4 May 2015 (UTC)
:::::Humm. I look in the compiler "help" system, and see for example <code>COMPLEX :: cube_root = (-0.5, 0.867)</code> both declaring and initialising a variable. Whether this value would apply to only the first invocation or to every invocation presumably depends on further opportunities for declaring STATIC and AUTOMATIC and SAVE, but no matter. PL/I also has a declare and initialise protocol.
:::::Humm. I look in the compiler "help" system, and see for example <code>COMPLEX :: cube_root = (-0.5, 0.867)</code> both declaring and initialising a variable. Whether this value would apply to only the first invocation or to every invocation presumably depends on further opportunities for declaring STATIC and AUTOMATIC and SAVE, but no matter. PL/I also has a declare and initialise protocol.
::::::No, it does not depend, it's only executed once. This is only a replacement for the DATA statement of Fortran 77. [[User:Arbautjc|Arbautjc]] ([[User talk:Arbautjc|talk]]) 05:34, 10 May 2016 (UTC)

So, the options are that a language/compiler
So, the options are that a language/compiler
:1) takes the expression at face value, computes both parts and then performs the '''or''' or '''and''', exactly as written.
:1) takes the expression at face value, computes both parts and then performs the '''or''' or '''and''', exactly as written.