On Tue, Oct 25, 2005 at 12:18:41PM -0600, Luke Palmer wrote:
> 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.
You can even do
sub foo (¢T $x --> T) {
my sub bar (T $z --> T) {
$z;
}
bar $x;
}
I do believe.
> Whereas if I wrote:
>
> sub foo (¢T $x --> ¢T) {
> my sub bar (¢T $z --> T) {
> $z;
> }
> bar $x;
> }
It would be semantically the same as above. (just like C<my $x; my $x>
would only declare one C<$x>, so too C<¢T $x ... ¢T $y> should only
bind one type to T (or ¢T) for the duration of the scope.
> 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 $x;
> }
I don't think so. In the first example all the T (or ¢T) are the same
type after the first ¢T (where the type is bound). In the second one
you'd get two separate types ¢T and ¢U. But ¢U would probably get bound
to the same type as ¢T as that's the type of thing that it returns
(assuming perl can figure that out).
That's if I understand Larry correctly.
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]