in reply to Re^5: Tim O'Reilly on Perl
in thread Tim O'Reilly on Perl

It does indeed have that already.

use v6; class test { has $.Property; } my $testing = new test; $testing.Property = 5; $testing.Property.say;

I beleive that it actualy uses a Proxy object with lvalue attributes, but don't quote me on that. ;)


___________
Eric Hodges

Replies are listed 'Best First'.
Re^7: Tim O'Reilly on Perl
by chromatic (Archbishop) on Jul 18, 2005 at 03:49 UTC

    Gah, ambiguous indirect object notation went away in Perl 6. Mark the invocant explicitly:

    my $testing = new test:;

    Or make a method call look like a method call:

    my $testing = test.new()

      Since the objects have no obvious public method new it makes more sense (to me) to call them in a magical sort of way. I don't see what adding the : to the end of the name does for anything. It certainly doesn't make it clearer. However new Object is pretty standard across many languages while your two examples are not. I would agree with using your second form on everything except new. It reads easier when you say $x is a (=) new Object.


      ___________
      Eric Hodges

        The colon marks the invocant of an indirect method call, at least if you're passing parameters. I realize you didn't pass parameters, but I recommend getting in the habit of always using the colon or never using indirect notation.

        The purpose of requiring the colon is to disambiguate the language. Indirect object notation fails in difficult-to-debug places in Perl 5 and the goal is to avoid that in Perl 6.

        The syntax and semantics of other languages don't really apply. This isn't C++ or Java. It's Perl 6. Unlike both languages, new is not a keyword in Perl 5 or Perl 6. It's a method call.

        If Dog.new is a burden, consider using an in-place mutator:

        my Dog $ralph .= new();