On 10/6/05, Dave Whipp <[EMAIL PROTECTED]> wrote:
> sub foo( $a, ?$b = rand but :is_default )
> {
>     ...
>     bar($a,$b);
> }
>
> sub bar( $a, ?$b = rand but :is_default )
> {
>    warn "defaulting \$b = $b" if $b.is_default;
>    ...
> }
>
>
> It would be unfortunate if the "is_default" property attached in &foo
> triggers the warning in &bar. So I'd like to say somthing like
>
>    sub foo( $a, ?$b = 0 but lexically :is_default ) {...}
> or
>    sub foo( $a, ?$b = 0 but locally :is_default ) {...}
>
> to specify that I don't want the property to the propagated.

This came up before when I proposed "lexical properties".  That was
before we knew that a property was just a role.  So you can do a
lexical property like so:

    {
        my role is_default {}   # empty
        sub foo($a, ?$b = 0 but is_default) {...}
    }
    {
        my role is_default {}
        sub bar($a, ?$b = rand but is_default) {...}
    }

If this turns out to be a common want, I can see:

    sub bar($a, ?$b = rand but my $is_default) {
        warn "Defaulted to $b" if $b.does($is_default);
    }

But I don't think it will be, and the empty role is easy enough.

Luke

Reply via email to