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: Fri, 16 Apr 2021 21:09:58 +0100 Organization: A noiseless patient Spider Lines: 36 Message-ID: <87mttydm95.fsf@bsb.me.uk> References: <87wnt2e06e.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="bcf9a544088c93a28385d943b82a88e7"; logging-data="6956"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PqbLH1QEOObdTrPBLmxwGMCx6jqm7xQs=" Cancel-Lock: sha1:kk24gbzIQDGssOm0X1PJ0kSVrBA= sha1:lzNSmzZ8jKNUdSNPdO9+sEaKjb0= X-BSB-Auth: 1.2f3c303faee06e3ee545.20210416210958BST.87mttydm95.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:39954 Jon Ribbens writes: > On 2021-04-16, Ben Bacarisse wrote: >> Jon Ribbens writes: >>> You most often see this sort of thing in JavaScript that was >>> automatically generated by a compiler (either because the original >>> source was in something else like TypeScript or a more modern version >>> of JavaScript or because the author wanted to compress/minify the >>> script), but human beings are also quite capable of writing hard-to-read >>> code like this. >> >> Is that specifically when the right-hand operand is an assignment >> expression? I don't find that hard to read but then I'm used to >> assignment being and expression so it seems like a natural extension of >> the more frequently seen uses of &&. > > I mean where it's an expression being abused as a control flow > mechanism. If readability is not the problem I'm not sure what constitutes abuse. Is it just a rule of yours to keep these two things entirely separate? Maybe some uses are acceptable and don't constitute abuse? Is any reliance on short-circuit evaluation in an expression an abuse? If so, does that extend to '??' and '?.'? (That's not easy to make clear in typing but I hope you know what I mean.) I only suggested that assignment might be where it crosses the line for you because I think that's where the line is for a lot of people, but it sounds like go further than that. I go the other way. Statements (most of them at least) are just wasted expression opportunities. It's less noticeable in ECMAScript, than in many other languages, but it still bugs me every now and then. -- Ben.