Eirik Berg Hanssen <[EMAIL PROTECTED]> wrote:

>   Which Perl5 (xor, undef) would this be?  It does not look like the
> result is undef around here:

> [EMAIL PROTECTED]:~$ perl -le 'print defined($_)?"defined":"undef", ": «$_»"
> for map {(undef xor $_), ($_ xor undef), (undef ^ $_), ($_ ^ undef)}
> "string", "", -1, 0, 1 , 2'

This "xor" is returning the bool values, which is quite different to
returning a value according to the xor of the booleans.

 perl -le 'print defined($_)?"defined":"undef", ": «$_»"
for map {(undef xor $_), ($_ xor undef)}
"string", "", undef, -1, 0, 1 , 2'

dropping bitwise xor, and including "undef xor undef" reveals that Perl5
has a different opinion then Parrot (or Perl6?).

inline op xor(out INT, in INT, in INT) :base_core {
  $1 = ($2 && ! $3) ? $2 : ($3 && ! $2) ? $3 : 0;
  goto NEXT();
}

static void
mmd_fallback_lxor_pmc(Parrot_Interp interp, PMC *left, PMC *right, PMC *dest)
{
    INTVAL left_truth, right_truth;
    PMC *true;
    left_truth = VTABLE_get_bool(interp, left);
    right_truth = VTABLE_get_bool(interp, right);

    if (left_truth && !right_truth)
            true = left;
    else if (!left_truth && right_truth)
            true = right;
    else {
        VTABLE_set_integer_native(interp, dest, 0);
        return;
    }
    VTABLE_set_pmc(interp, dest, true);
}

We need language lawyers ;)

leo

Reply via email to