$ by itself is a an anonymous state variable. So these two lines would be exactly the same.
$.foo (state $).foo A feature was added where $.foo would instead be used for public attributes. Since a public attribute just adds a method, it was allowed to use it to call any method. Which probably made it simpler to add. (Note that calling a method on an anonymous variable doesn't make much sense anyway, so there is no big loss.) Basically it was made so that these two lines would be the same: $.foo $( self.foo() ) Using : on the method was probably just overlooked, because that is not what that feature is meant for. On Tue, Nov 19, 2019 at 12:04 AM Raymond Dresens <raymond.dres...@gmail.com> wrote: > Hello Vadim, Yary, > > Thanks for your feedback, > > I've filed an issue: https://github.com/rakudo/rakudo/issues/3306 > > Yary, about the dollar sign, > > The snippet of code in the issue shows that expression "$.attribute" > inside a method 'just works' for accessing individual attributes (or > rather: implicitly invoking their accessors?), suggesting [to me] that the > variable '$' can be used in the context of method lookup on "self". I would > expect that it would work too when I try to invoke an attribute as a > method... > > ...though solely printing '$' in a method yields "(Any)", not the same as > printing "self"! Indeed: there's more going on that meets the eye, which > makes me curious ;) Perhaps the docs mention why, I'll look for that when I > have the opportunity to do so, > > Regards, > > Raymond. > > On Mon, 18 Nov 2019 at 18:13, Vadim Belman <vr...@lflat.org> wrote: > >> >> I would say filing an issue might make sense in this case. Here is a >> related comment from Jonathan: >> https://github.com/rakudo/rakudo/issues/3222#issuecomment-539915286 – >> and it explicitly states that $. is a shortcut for method calling. >> Therefore, use of colon instead of braces should be a valid construct. >> >> Best regards, >> Vadim Belman >> >> On Nov 18, 2019, at 11:40 AM, yary <not....@gmail.com> wrote: >> >> I take that back! What is the dollar sign doing there in the '$.print: >> ..." example? >> >> Try it without the dollar sign. Right now you're calling .print on the >> anonymous variable '$' >> >> -y >> >> >> On Mon, Nov 18, 2019 at 8:38 AM yary <not....@gmail.com> wrote: >> >>> 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 >>> >> >>