On 10/25/05, Larry Wall <[EMAIL PROTECTED]> wrote:
> We're probably converging on a general rule that two or more
> declarations of the same variable in the same scope refer to the
> same entity:
>
>     my $x = 1;                  # outer $x;
>     {
>         $x = 2;                 # bound to OUTER::<$x>
>         if my $x = foo() {...}  # new $x declared here
>         if my $x = bar() {...}  # same $x, "my" is optional
>         baz();                  # baz sees single inner CALLER::<$x>.
>     }

...

...

Cool!

> So too these would mean the same thing:
>
>     sub Bool eqv (¢T $x, T $y) { my T $z; }
>     sub Bool eqv (¢T $x, ¢T $y) { my ¢T $z; }

I like that symmetry between &foo and ¢foo.  So to get the behavior
that an outer type variable applies to an inner sub, could I do this:

    # a complicated identity function :-)
    sub foo (¢T $x --> ¢T) {
        my sub bar (T $z --> T) {
            $z;
        }
        bar $x;
    }

Because omitting the ¢ would not bind T.  Whereas if I wrote:

    sub foo (¢T $x --> ¢T) {
        my sub bar (¢T $z --> T) {
            $z;
        }
        bar $x;
    }

It would be a totally new variable in both spots in the inner sub, and
if I wrote:

    sub foo (¢T $x --> ¢T) {
        my sub bar (T $z --> ¢T) {
            $z;
        }
        bar $x;
    }

It would be equivalent to:

    sub foo (¢T $x --> ¢T) {
        my sub bar (T $z --> ¢U) {
            $z;
        }
        bar $z;
    }

(Thus causing a "signature too general" type error)

Right?  Totally off?

Luke

Reply via email to