Problem with using && as shorthand for if
Ersin Er
ersin.er at gmail.com
Fri Aug 20 14:09:56 PDT 2010
On Sat, Aug 21, 2010 at 00:00, div0 <div0 at sourceforge.net> wrote:
> 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.
If Andrei is wrond and DMD is right, then the first example should not have
compiled too..
> --
> My enormous talent is exceeded only by my outrageous laziness.
> http://www.ssTk.co.uk
>
--
Ersin Er
http://metasolid.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100821/f3cd26df/attachment-0001.html>
More information about the Digitalmars-d-learn
mailing list