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: Sun, 18 Apr 2021 17:26:18 +0100 Organization: A noiseless patient Spider Lines: 46 Message-ID: <8735vn7e51.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="cebc7205e7af165aaf5b3baa2f235ea5"; logging-data="17417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18k/f77od8XAjbTWGaztVFJkGYaNTwYN9k=" Cancel-Lock: sha1:fSqZ0pENEMZ/qopcABJaFNRxqMI= sha1:PHVr0VUnNUDQZr0JJZ0KZi3M3aw= X-BSB-Auth: 1.115429f8e0f6ea121e40.20210418172618BST.8735vn7e51.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:39976 Arno Welzel writes: > Ben Bacarisse: > >> Jon Ribbens writes: > [...] >>> It's not a rule of mine, it seems to be a rule of almost everyone. >> >> The trouble is that a non-trivial number of languages have this form, > > Yes - but this is more a side effect than a intended way to use those > languages. I think that's likely in most cases, but Perl added 'and' and 'or' with the same semantic as it's existing && and || but with much lower precedence so that they could be used for this kind of thing more easily. > [...] >> I've seen (and, dare I say, written) code that uses the result. I >> wonder if that absolves the programmer from the charge of abuse: >> >> return (data = parse_input(file_name)) >> && (result = transform(data)) >> && write_file(file_name); > > In a polite way I'd say this is the result of someone who is really lazy > and want's to avoid typing as much as possible. That's ok if you do a > project just for yourself. But as soon as you need to work in a team, > readibility *is* more important than having the shortest possible > code. I never aim to the shortest code, but readability is not an absolute. Who is doing the reading? Do we assume, for the purposes of assessing readability, the very lowest absolute minimum understanding? I don't think I've worked with any colleagues who would have the slightest trouble reading that statement. I fully admit that my experience is probably atypical, but some people just work in an environment with different notions of what is hard to read. By the way, I'm not suggesting that there could not be other good reasons to re-write such things, just that there may be environments in which its readability would not come up as an issue. -- Ben.