[EMAIL PROTECTED] writes:
: Aaron wrote:
: 
:    > Several questions come up.
:    >
:    >    * If $.foo is "like" the Perl5 $self->{foo},
: 
: Except (as I'm sure you know) that Perl 6 class instantiations aren't
: hashes, and their attributes aren't hash entries.

Nevertheless, *using* one as a hash might work, as long as you don't
try to create non-existent accessor methods.

:    >    * Is "foo" in this context an auto-quoted key, or an
:    >      actual entry in the namespace? I ask because I'm
:    >      trying to find out how this interacts with Perl's
:    >      (un)reserved words.
:    >
:    >            print $.if 1; # comes to mind
: 
: This is:
: 
:          print ${'.if'} 1;      # syntax error
: 
: not:
: 
:          print $. if 1;

Since $. is going away in favor of a filehandle attribute, we can treat
$. as a prefix just like $# is currently.  So $.if should be fine.

:    >    * Do you always have to use parens now for method invocation?
: 
: No.

Except when interpolating a method call.

:    > I'm quite curious to see what the initialization syntax will be like.
: 
:         class Demo {
:                 my $foo;
:                 my $bar;
: 
:                 method INIT ( $fooval, $barval) {
:                         $foo = $fooval;
:                         $bar = $barval;
:                 }
: 
:                 method foo is lvalue {
:                         return $foo;
:                 }
:         }

Ick.  I don't want to lose the dots that visually distinguish instance
variables from ordinary lexicals, and simultaneously render the extra
bracketing and indentation unnecessary.  I'd write the above as:

    class Demo;

    my $.foo is public;
    my $.bar;

    method INIT ($fooval, $barval) {
        $.foo = $fooval;
        $.bar = $barval;
    }

If you want to limit the scope, you can always bracket around the whole
thing, just as with the package declaration.  And I'd like "class" and
"module" to just be variants of the "package" keyword.  That makes them
easier to teach.

Larry

Reply via email to