:: Re: [DNG] [OT] [Re: Studying C as t…
Etusivu
Poista viesti
Vastaa
Lähettäjä: KatolaZ
Päiväys:  
Vastaanottaja: dng
Aihe: Re: [DNG] [OT] [Re: Studying C as told. (For help)
On Tue, Jun 21, 2016 at 05:47:59PM +0900, Simon Walter wrote:

[cut]

> >Be careful, because conditional expressions in C are subject to
> >"short-circuiting", meaning that only the minimum number of
> >expressions sufficient to determine the value of a chain of && and ||
> >will be evaluated. In particular, a chain of || expressions will be
> >evaluated until there is one that evaluates to TRUE (!=0), while a
> >chain of && is evaluated until there is one of them which evaluates to
> >false (==0).
> >
>
> Isn't that how AND and OR work in most programming languages? Mind you, I am
> not familiar with that many.


I didn't say that short-circuiting is a peculiarity of C :) I simply
said that short-circuiting is how C evaluates conditional
expressions. There are many cases (such as that of FORTRAN) in which
short-circuiting can be enabled or disabled at compile time, many
other cases (e.g. most of the dialects of BASIC and some other
esoteric languages) in which short-circuting does not exist, and many
more cases in which the language supports both eager and short-circuit
boolean operators (e.g., Java, Python, Perl, Ruby, etc.)

Boolean expressions in C are always subject to short-circuting.

HND

KatolaZ

-- 
[ ~.,_  Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab  ]  
[     "+.  katolaz [at] freaknet.org --- katolaz [at] yahoo.it  ]
[       @)   http://kalos.mine.nu ---  Devuan GNU + Linux User  ]
[     @@)  http://maths.qmul.ac.uk/~vnicosia --  GPG: 0B5F062F  ] 
[ (@@@)  Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ  ]