I see that the following is a common idiom in Julia:

...
flag = true
...
flag && (x = rand(2,2))
...

which is very handy and concise, but seems to contradict the restriction 
stated in the 
documentation<http://docs.julialang.org/en/latest/manual/control-flow/?highlight=short%20circuit#short-circuit-evaluation>:
 
"Just like condition expressions used in if, elseif or the ternary 
operator, the operands of && or|| must be boolean values (true or false). 
Using a non-boolean value is an error".  Should the documentation be 
amended here?  Is any kind of assignment allowed on the RHS, as long as it 
is enclosed in parentheses? What about other kinds of statements on the 
RHS?  I note that if the positions of the two operands of && above are 
reversed, an error is generated, complaining about a non-boolean type used 
in a boolean context.

--Peter

Reply via email to