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). > 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. > 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? 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 ;). Dave Isa. 40:31