Here is Damian's module to allow one to play with the new variable syntax for Perl 6. Many of us are clearly at odds with getting rid of arrow syntax. It is certainly more readable (it gives visual space between referer and referee). And it is going to be a major point by which many Perl 5 programs are going to be non-Perl 6 truly compliant even if they run.

And what is the motivation for the change? Is there a very good reason to do this? I have heard it brings Perl more inline with other langauges, but what kind of selling point is this? Perl is a very different language. In a class of its own.

Replies are listed 'Best First'.
Re: Death to Dot Deref
by osorronophris (Novice) on May 19, 2001 at 00:23 UTC
    Correct me if I'm wrong, but as far as dereferencing goes, in Perl 6 it should be implicit (which can be good or bad) so one should never have to type $foo.{bar}. The . will be unnecessary. That's OK (tm).

    What I am opposed to is the use of . for method calls. Currently $object->method is quite distinct from $object->{attribute}. With the addition of properties (like $node{VALUE}.Found in Exegesis 2) how are we supposed to differentiate methods from other things?

    There just doesn't seem to be enough reason to make this change. Sure it's just syntactic. But one of the great things about Perl is that one can generally tell exactly what one is looking at, as opposed to hunting through thousands of lines of code to find out if foo is type char or int.

Re: Death to Dot Deref
by srawls (Friar) on May 19, 2001 at 00:11 UTC
    Well, I like the new conventions. Also you don't even have to use this:
    $foo.{$k}
    Since to acces a hash you would use % and not $, then the compiler can assume it is a reference. Personally I think that $foo->{$K} is better to the eye than $foo.{$k}, but I prefer $foo{$k} to anything.

    Also, I do like the dot in this case:

    $obj = new SomeModule; $obj.DoSomething(); #as opposed to $obj->DoSomething();
    I guess that is just because I come from a c/c++ background : )

    The 15 year old, freshman programmer,
    Stephen Rawls
      Technically though, using -> for method calls is correct since all Perl objects are really just blessed references. In C or C++ if you access an attribute or call a method from a pointer/reference you do foo->bar as well.

      So while "." may hide the reference structure from you, "->" is technically correct. Course that may not be applicable for Perl 6.

      This auto-deref seems to be a good thing. C++ compilers could do it, but in C-language school of leaving it up to the programmer to say what they mean, and mean what they say, they won't.

      It would seem that under Perl 6, if a hash-type reference is made to what is a hash-ref, then it dereferences automatically, which enables the equivalence:
      my $foo = {}; $foo{x} = "Bar"; # Auto-dereference $foo->{x} = "Bar"; # Manual dereference
      This sort of behaviour already occurs after the variable is resolved, as in:
      $foo->{y}->{z} = "Zoinks"; print "$foo->{y}{z}"; # Perl5 Auto-dereference
      Under C/C++, there is a huge difference between an object reference, an object pointer, and a stack object. In Perl, though, you could hardly care less where the object is as Perl should be able to figure it out for you.

      From a point of style, though, I would have to agree with srawls in that using '.' with hash or list variables is a bit wacky. It makes a lot more sense when used with object references.