Talk:Short-circuit evaluation: Difference between revisions

Line 80:
:I think that for this task, if it is not a feature of the language then this should be noted, especially if it can legitimately become a feature of a compiler or is a feature of a popular compiler. If you know that you are depending on a feature of particular compilers/compiler optimisation settings then this should be stated. You can also do a nested-if solution for the general case. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 05:27, 2 May 2015 (UTC)
::See [https://software.intel.com/fr-fr/forums/topic/282534 this discussion] about Intel Fortran and its ancestors VAX Fortran and Compaq Visual Fortran, and why it's indeed a good thing _not_ to have short-circuit evaluation. I don't know a compiler that would provide this as an option, however my experience is limited to gfortran and the commercial compilers of Intel and Absoft, and even with these I may have missed an option. VAX Fortran was said to have this, but Steve Lionel has stated on several occasions that it was not so. I'd say that having both like Ada would probably be better, and actually there have been discussions in 2004 about new operators .ORELSE. and .ANDTHEN., resulting in a proposition by Van Snyder [http://j3-fortran.org/doc/year/04/04-390.ps]. See also document N1972 at WG5 [ftp://ftp.nag.co.uk/sc22wg5/N1951-N2000/N1972.pdf]. Maybe they will eventually get their way into the standard. Anyway, they are not part of the current draft of Fortran 2015 [http://j3-fortran.org/doc/year/15/15-007.pdf]. [[User:Arbautjc|Arbautjc]] ([[User talk:Arbautjc|talk]]) 21:45, 2 May 2015 (UTC)
 
:::The turbo Pascal compiler offered a B+ or B- option to choose full or short-circuit evaluation, though I don't know of any such option in a Fortran compiler. On the one hand are the simple and clear usages for ''safe & test'' and on the other are vague murmurings about unspecified potential optimisations that might involve possible parallel execution via multiple cpus or code reordering (apparently ignoring the left-to-right rule) and any amount of hand-waving. That the modern fortran standard supports the latter does not mean its words deserve respect as holy writ from on high, especially as I have often wanted the simple scheme to work and have not seen any actual gain from the fog of vapour-optimisations. Suggestions such as .OR ELSE. sound vaguely threatening! With Compaq V. Fortran, sometimes this worked and other times not, the determinant being the precise nature of the expression and operands and vagaries of compiler choices involving register allocations or whatnnot. Although conforming to the inspecificity of the standard, I don't think this is a good thing at all. I prefer definite and understandable behaviour! Which I can then take advantage of. And such reliance becomes my mistake, since the standard's choice is not mine. Fortunately, only a few usages had to be repaired, but others, especially where the compiler happens to choose short-circuitry, may lurk. [[User:Dinosaur|Dinosaur]] ([[User talk:Dinosaur|talk]]) 12:21, 4 May 2015 (UTC)
1,220

edits