Perl6 RFC Librarian <[EMAIL PROTECTED]> writes:
> This and other RFCs are available on the web at
> http://dev.perl.org/rfc/
>
> =head1 TITLE
>
> C<my Dog $spot> is just an assertion
>
> =head1 VERSION
>
> Maintainer: Piers Cawley <[EMAIL PROTECTED]>
> Date: 13th September 2000
> Mailing List: [EMAIL PROTECTED]
> Number: 218
> Version: 1
> Status: Developing
>
> =head1 ABSTRACT
>
> The behaviour of the <my Dog $spot> syntax should simply be an
> assertion of the invariant:
>
> (!defined($spot) || (ref($spot) && $spot->isa('Dog)))
>
> =head1 DESCRIPTION
>
> The syntax
>
> my Dog $spot = Dog->new();
>
> currently carries little weight with Perl, often failing to do what
> one expects:
>
> $ perl -wle 'my Dog::$spot; print "ok"'
> No such class Dog at -e line 1, near "my Dog"
> Execution of -e aborted due to compilation errors.
> $ perl -wle 'sub Dog::new; my Dog $spot; print "ok"'
> ok
> $ perl -wle 'sub Dog::new; my Dog $spot = 1'
> ok
>
> The first example is obvious, as is the second. The third one is
> I<weird>.
Actually, it's *very* weird given that there's no code to print 'ok'.
Which is bad.
$ perl -wle 'sub Dog::new; my Dog $spot = 1; print "ok"'
That's better.
--
Piers