octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: short circuit & and | in if and while


From: Ernst Reissner
Subject: Re: short circuit & and | in if and while
Date: Thu, 14 Sep 2017 03:25:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

Yes, Mike, I know the what, but not the why and I really cannot figure
out a reason.
The reason why I ask is among other things, what about until in octave:
Maybe short circuiting should be also for until, as it is for while and if:
while (false & error("both")) "hi";end shortcuts and thus no error while
do "hi" until(true |error("both")); yields and error.

This seems a little inconsistent,
but on the other hand, ... what sense makes the matlab feature at all?!

> On Thu, Sep 14, 2017 at 02:15:16 +0200, Ernst Reissner wrote:
>> Is there anyone who can explain me,
>>
>> why in matlab, and thus in octave,
>>
>> if(a&b) is interpreted like if(a&&b),
>>
>> whereas c=a&b differs from c=a&&b
>>
>> which means that
>>
>> if(a&b) is not the same as c=a&b;if(c)...
>>
>> Very strange.
>>
>> This feature also applies to while but not to until...
>>
>> Who can explain me???
> Here is an official answer from Mathworks Support that describes the
> behavior
>
>   
> https://www.mathworks.com/matlabcentral/answers/99518-is-the-logical-operator-in-matlab-a-short-circuit-operator
>
> This is a "what", not a "why". I don't know who you can ask for an
> answer to "why", it just is.
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]