On Sat, May 19, 2001 at 11:30:40AM +1000, Damian Conway wrote:
> I obviously didn't do an adequate job the first time.

I don't know about that, but the universe of Perl 6 properties is
looking clearer to me now and I thank you for it.

> Here, the C<true> property is being set I<on the value> in $result and that
> annotated value is then being returned. We might want to do this because
> we know the value could be 0 or "" or "0", but we'd still like to be
> able to write:
> 
>         if ($res = gorkulator) {
>                 ...
>         }

This seems to imply that conditionals will look at certain properties
(true/false). I hope not.  I'd rather that properties be explicitly
checked:

        if (($res = gorkulator).true) {
            ...
        }

If anything, all variables should have a "value" property that evaluates
to its, well, value and only that property would be considered in
conditionals.  Then these would be equivalent:

        print keys (+$foo).prop;
        print keys $foo.value.prop;

and perhaps that would satisfy the (+$foo).prop-is-ugly slice of
people.


>         $bar is Open;
>         $bar is Open("from 5pm");
>         $bar{soom} is Open("from 5pm");
>         "bar" is Open("from 5pm");
>         1 is Open("from 5pm");
> 
> Note that in the first three of the above cases, it's the I<value in the
> variable> -- not the variable itself -- that has the C<Open> sticky-note
> attached to it.

How do we know it applies to the value and not the variable?  Is it
the presence of "my" that would make the difference?  What about
these:

        our $food is ready;             # compile-time?
        temp $erature is rising;        # run-time?

And if it is the "my" that makes all the difference, this will need
good documentation (and appropriate warnings):

        sub CheckBar {
            ...
            return my $bar is Open;
        }
        $barstat = CheckBar();
        if ($barstat.Open) { ... }      # Oops, $barstat.Open doesn't exist


> The answer is that methods always override property accessors of the
> same name.

...

> You may also be wondering what happens if a variable and the value it
> contains both have a property of the same name. The answer is that we
> always get back the variable's property in preference to the value's:

So, if I have a Dog $spot, here's a little table where a 1 in the M
column means $spot has a bark method that says 'woof', 1 in the V column
means $spot has a bark variable (compile-time) property that says 'arf'
and a 1 in the A column means $spot has a bark value (run-time) property
that says 'yip'.

MVA     $spot.bark      (+$spot).bark
000     Error           Error
001     yip             yip
010     arf             Error
011     arf             yip
100     woof            woof
101     woof            woof
110     woof            woof
111     woof            woof

yes?

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to