At 5:47 PM -0500 12/3/02, David Robins wrote:
On Tue, 3 Dec 2002, Dan Sugalski wrote:At 4:29 PM -0500 12/3/02, David Robins wrote: >Enlightenment appreciated as always. This is something that'll come up with perl 6 reasonably soon as well. The solution for us is to have truth and falsehood be an optional property on the variable, potentially separate from the variable's value. The mechanism for that's not in yet. (I'd forgotten. It's on the todo list now)Was this discussed earlier (and if so, got a link?) or just sketched out and /* TODO */'d?
Just sketched out and TODO'd.
True, but I'm looking at the boolean state of a variable as potentially part of a larger set of things. I freely admit a boolean PMC with a true value and a false property would be really bizarre. (So I'd suggest that you make it so that can't happen... :)Adding an extra knob doesn't seem like all that good a solution (seems you'd run into weird issues, like a boolean PMC that was both true and false at the same time, or an undef value that was true); why not -
It is OK for an undef value to be true, though. That's not only allowable, it has to be allowed. For perl, at least, it's how Larry plans on getting around the "function returns undef, but it's a real undef value, not a false 'I didn't work' value" issues we have in perl 5 now.
- create immutable "true" and "false" PMCs
That's fine.
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?)- have not P0, P1 set P0 to $1->get_bool ? true : false
Not for these, though. Logical and, or, and xor need to be delegated to the PMCs as they may be overridden, and binary logical operations may return something other than a plain true or false value. Otherwise perl's short-circuiting logical stuff behaves... oddly. And I know that can be overridden.- and P0, P1, P2 set P0 to $1->get_bool ? $2->get_bool ? $2 : $1 : false - or P0, P1, P2 set P0 to $1->get_bool ? $1 : $2->get_bool ? $2 : false - xor P0, P1, P2 set P0 to whichever is set, false if both/neither
Maybe. Would any compiler actually use this, though? I don't often care about what opcodes we put in, but apparently today I do.- plus optionally allow a not Ix, Px op which sets Ix to 1 or 0, etc.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk