At 6:58 PM -0500 12/9/02, David Robins wrote:
On Mon, 9 Dec 2002, Dan Sugalski wrote:

 At 12:27 AM +0000 12/7/02, Alex Gough wrote:
 >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.

 D'oh! Now it's obvious.
 I've been conflating the two, which is wrong.
 The get_bool vtable method is specifically to retrieve the boolean
 state of a PMC. It returns 1 or 0, true or false, and we use it to
 check truthfulness.
 We need a logical_not vtable entry that returns a full-fledged PMC
 that's the logical complement of the not-ted variable.
As in one that actually allows creation of one, or the same as already
exists (which does not let one [easily] return a full PMC, just call vtable
methods on the one passed in).
Right. It's up to the language implimentor (and PMC class implimentor) to decide what the right thing to return is.

 > So "if (!$foo)" probably translates to "unless $foo, BAR" and under
 the hood does a get_bool on $foo. On the other hand, "$foo = !$bar"
 calls "not $foo, $bar" and $bar is in a position to decide what it
 isn't.
What about "if($a = !$foo)"?  Or: "if(!!$foo)" or "if($a = !!$foo)"?  Or if
it's part of a bigger expression: "if(($a && !$b) || ($c && !$d))"?  Or
"if((!$some_set).union($other_set))"?  I think using "unless" is more of an
optimization than a "default" encoding for not, even if it isn't assigned
anywhere permanent.
That's language-dependent. I can certainly see it going any one of a half-dozen ways, and it's up to whoever defines their language's behaviour to say how it should work. Parrot can go either way, since we really shouldn't care.


 If a language really needs "if (!$bar)" to get a full-fledged not-ted
 $bar and then test it for truthfulness, it can emit "not $$temp,
 $bar; if $temp, FOO" or something very much like it.
What type is $temp?
A temporary PMC of some sort. I bobbled the dollar signs there.

Or are logical_not et al. to be changed to be able to actually _return_
a PMC rather than just modify a given destination PMC?

I'm sorry to be asking a lot of pesky questions; it's not personal, just
business ;).
Pesky questions are important, as they point out a place where someone didn't think clearly. In this case, that someone'd be me. :)

--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk

Reply via email to