logic ops with zero-extent raw vectors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

logic ops with zero-extent raw vectors

Lukas Stadler
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.

Best,
 Lukas
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: logic ops with zero-extent raw vectors

Martin Maechler
>>>>> Lukas Stadler <[hidden email]>
>>>>>     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]]

    > ______________________________________________
    > [hidden email] mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel