Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Understanding && Date: Sat, 17 Apr 2021 15:50:41 +0100 Organization: A noiseless patient Spider Lines: 27 Message-ID: <87y2dharsu.fsf@bsb.me.uk> References: <87wnt2e06e.fsf@bsb.me.uk> <87mttydm95.fsf@bsb.me.uk> <87o8edd8qk.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="4e3f27b6ab499a3bcc0c30dc0654f2f4"; logging-data="5572"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1D5LuBDF6CbI6HAEk2mtoZC0E6Cvn7hg=" Cancel-Lock: sha1:bJFGlqCVAkaxsfedaK+K3bg6i3c= sha1:jyc7XHKZBEz2F3oDvD5pywrN7I0= X-BSB-Auth: 1.a61030a08f8cc4120e79.20210417155041BST.87y2dharsu.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:39960 John G Harris writes: > On Sat, 17 Apr 2021 02:01:55 +0100, Ben Bacarisse > wrote: > > >>If you >>don't mind, can say if the problems you have with its readability is >>down to there being an assignment on the right, or is it with any use of >>&& that relies on the short-circuit evaluation. > > > Two ways of writing it imply different purposes : > > if A is true then Do B > where the emphasis is on Doing. > > if A is true then it's safe to Evaluate B > where the emphasis is on Evaluating. Thanks. I don't find the "do" vs "evaluate" so clear cut, but I get that you want to keep them separate. The two get mixed up because sometimes we want both. And functions that do things and return values make sense (to me) on either side of &&. -- Ben.