in reply to Re^3: Better expression for $x = !!$y||0
in thread Better expression for $x = !!$y||0

Just to let you know we fixed this, in Perl 6 this is written:
$x = ?$y;
And the standard operators like == are expected to return 0 or 1 when a boolean result is expected. (Boolean context will still accept any true value, as in Perl 5, and the short-circuit operators still return one of the input values as the "true" value.),

Yes, you can still overload these to return something other than 0 or 1, but it would be construed as antisocial.

Replies are listed 'Best First'.
Re^5: Better expression for $x = !!$y||0
by ysth (Canon) on Apr 20, 2005 at 07:07 UTC
    in Perl 6

    ...

    Yes, you can still overload these to return something other than 0 or 1, but it would be construed as antisocial.

    That's exactly how I feel WRT doing this in perl5.
      Except Perl 5 makes no such guarantee. A lot of the built-ins return "" or 1 instead, for instance.
        Do you mean sv_yes or sv_no (which has PV "" and IV 0)? Or the very few things that actually return either "" or 0 instead of sv_no? IIRC correctly, there are good reasons for those odd cases.