looks like a bug to me-file an issue on the rakudo GitHub

On Sat, Nov 16, 2019 at 5:29 AM Raymond Dresens <raymond.dres...@gmail.com>
wrote:

> Hello,
>
> I have a question related to the 'colon syntax' of Raku, which allows
> you to call methods without parenthesis like this:
>
>     class Foo
>     {
>         method print($x, $y)
>         {
>             say "bar: {$x}, {$y}"
>         }
>     }
>
>     my $a = Foo.new;
>
>     $a.print: 3, 5; # ...this is what i mean with "colon syntax" ;)
>
> It is possible to use this syntax to call methods on 'self' as well:
>
>     class Bar is Foo
>     {
>         method printDefault
>         {
>             self.print: 8, 12
>         }
>     }
>
>     my $b = Bar.new;
>
>     $b.printDefault;
>
> I use $. rather than 'self' in order to work with attributes inside
> methods in my classes, well, ... mostly, because it does not seem
> possible to do this (in rakudo, at least version 2019.07.1):
>
>     class Baz is Foo
>     {
>         method printDefault
>         {
>             $.print: 8, 12
>         }
>     }
>
> This yields a "Confused" error, stating that it expects a so-called
> 'colon pair'.
>
> Is this intentional? Because I'm kind of confused as well about this,
>
> I can live with this 'syntactical quirk', but I just keep wondering
> about it because I'd personally expect that this "$.methodname: $args"
> variant should "just work" as well...
>
> ...so "what gives"? ;)
>
> Thanks for your insights!
>
> Regards,
>
> Raymond.
>
-- 
-y

Reply via email to