Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Uniary operator following arithmetic operator

$
0
0

! (ifort version 15.0.0 or earier)
!  I think it is a bad idea to extend the grammer of the arithmetic expression
! in Fortran langurage as the followings.
! Such functionality might look convenient at first, however it would enhance

!possibilities to make the compiler to silently ignore  possible human-errors

! such as mis-types especially in lengthy expressions.

 

ifort accepts the source code below without errors nor warnings.

---------------------------

program to_be_avoided
implicit none
real a, b, c, d, e, f, g, x, y, z, w
   a = --3.0
   b = ++3.0
   c = -+3.0
   d = +-3.0
   e = 2.0 +-3.0
   f = 2.0 *- 3.0
   g = 2.0 *+ 3.0
   x = 2.0 *- 3.0
   y = 2.0 /- 3.0
   z = 2.0 +-+ 3.0
   w = 2.0 +-+----- 3.0
   !----
   a =  2.0 ++ a / x
   b = --y
   c = +-w
   d = y *- x
   e = z /+-a
   f = -- y ++ a /- x
   g = -- y ++ a / -----x
   x = -a **-x
   y = -+a **--x
   z = --a **+ x ** y
   w = sin(++2.0) -- sin(x--y)
! integer expressions as well (omitted).
end program to_be_avoided
---------

You can also compare with GNU's gfortran or other compilers.

AttachmentSize
Downloadto_be_avoided.f90916 bytes

Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>