[Rd] logic ops with zero-extent raw vectors

Martin Maechler maechler at stat.math.ethz.ch
Thu Sep 28 10:17:04 CEST 2017


>>>>> Lukas Stadler <lukas.stadler at oracle.com>
>>>>>     on Wed, 27 Sep 2017 17:36:15 +0200 writes:

    > Hi,
    > there was a change concerning logical operations about a year ago:
    > https://github.com/wch/r-source/commit/9e19d3e3dd5f657b5cfefe562bdd7ede2e2b8786
    > It's related to a discussion on this list:
    > https://hypatia.math.ethz.ch/pipermail/r-devel/2016-September/073068.html <https://hypatia.math.ethz.ch/pipermail/r-devel/2016-September/073068.html>

    > A change in logic.c:134 influences the result type of operations on zero-extent raw vectors.
    > Old behavior:
    >> raw(1) & raw(1)
    > [1] 00
    >> raw(0) & raw(0)
    > raw(0)
    > New behavior:
    >> raw(1) & raw(1)
    > [1] 00
    >> raw(0) & raw(0)
    > logical(0)

    > I'm wondering whether the logical result type was intentional, because, to me, the old behavior seems more consistent.

Yes, logic operations on raw()s should remain raw() as always
documented.  Indeed, this is a bug introduced (to the source)
more than a year ago.  It is amazing that it had not been
noticed earlier.

Thank you, Lukas, for the report!

I'll fix it .. but of course too late for R version 3.4.2  which
has been released  about one hour ago (!).

Martin Maechler
ETH Zurich

    > Best,
    > Lukas
    > [[alternative HTML version deleted]]

    > ______________________________________________
    > R-devel at r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list