[Rd] ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1

Joris Meys jori@mey@ @ending from gm@il@com
Thu Aug 30 14:48:01 CEST 2018

On Thu, Aug 30, 2018 at 2:09 PM Dénes Tóth <toth.denes using kogentum.hu> wrote:

> Note that `||` and `&&` have never been symmetric:
> TRUE || stop() # returns TRUE
> stop() || TRUE # returns an error
Fair point. So the suggestion would be to check whether x is of length 1
and whether y is of length 1 only when needed. I.e.


would give an error and


would pass.

Thought about it a bit more, and I can't come up with a use case where the
first line must pass. So if the short circuiting remains and the extra
check only gives a small performance penalty, adding the error could indeed
make some bugs more obvious.


Joris Meys
Statistical consultant

Department of Data Analysis and Mathematical Modelling
Ghent University
Coupure Links 653, B-9000 Gent (Belgium)

Biowiskundedagen 2017-2018

Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]

More information about the R-devel mailing list