Problem with using && as shorthand for if
    div0 
    div0 at sourceforge.net
       
    Fri Aug 20 14:00:22 PDT 2010
    
    
  
On 20/08/2010 21:16, Jonathan M Davis wrote:
> It's legal according to TDPL. It seems to be intended to be used as a shorthand
> for if. So, stuff like
>
> condition&&  writeln("my output");
>
> are supposed to be perfectly legal as bizarre as that may seem. I don't believe
> that it would be legal to do
>
> if(condition&&  writeln("my output"))
> {
> }
>
> since the result fed to if must be a bool, but a statement doesn't need to
> result in bool, so apparently you can use&&  with a void function in a
> statement. It's just that the void function must be last.
>
> - Jonathan M Davis
Then Andrei has taken leave of his senses and this is one situation 
where DMD is corrent and TDPL is wrong.
Half arsed, moronic shortcuts like that belong in scripting languages 
and shell environements, not serious programming languages.
-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
    
    
More information about the Digitalmars-d-learn
mailing list