On Sat, 7 Dec 2002, Alex Gough wrote:

> #### [Fri, Dec 06, 2002 at 05:01:21PM -0500: Dan Sugalski]
....
> > >- have not P0, P1 set P0 to $1->get_bool ? true : false
> >
> > Sure, that works. I can't think of a good reason to have PMCs be able
> > to return something fancier than true or false when we ask them for
> > their logical negation. (Can any language override logical negation
> > to return something besides true/false?)
>
> Be careful not to stop people doing interesting, useful but entirely
> sick things.  Current perl has problems rooted in the way it deals
> with overloading and tieing that mean some things can't be done
> without lots of rewriting.
>
> I'd say that any operation who's result could be stored somewhere
> should (nay, must) be able to return a fully fledged PMC.

But right now, they can't do that, because the 'PMC* dest' could be any type
(I suppose every logical op handler could destroy dest and init whatever
type it actually wants to return, but - even if that's legal - it's a little
tacky).  All that can be done is to call methods on the existing destination
PMC, which is pretty restrictive sometimes, e.g. in the case of RubyInteger
which is never false (no, not even 0).

> That is to say, in "if ( !exp1 ) { ... }", !exp1 merely has to be true
> or false, while $foo = !exp1 leaves !exp1 needing to be all manner of
> things.

But !exp doesn't need to translate to evaluating exp and then using the not
op.  You could parse it so that '!' is the postincrement operator if you
like, and generate IMCC accordingly.  Or that '!' does 'invoke("!")' on your
PMC, which can do many weird and wonderful things.

By definition 'boolean not' should return a boolean value, and should work
in a fairly predictable way on _any_ PMC, to aid interoperability between
parrot targets; ditto for and/or/xor; and (as outlined in my previous
message to the list) only get_bool needs to be implemented to provide for
the whole set of logical ops.

I suppose it boils down to whether 'and' means 'semi-predictable white box
logical and' or 'Yet Another Operator Name To Abuse', much the same way that
sick and twisted people can override C++ operators to do evil things :>.

Dave
Isa. 40:31

Reply via email to