Re: callbacks with placeholder vars

2021-08-25 Thread Daniel Sockwell
I just submitted a PR based on this useful thread. https://github.com/Raku/doc/pull/3942 Thanks to you both! (Also, apparently $:a has the same behavior – after the first time, you can use $a )

Re: callbacks with placeholder vars

2021-08-09 Thread Patrick R. Michaud
On Mon, Aug 09, 2021 at 01:00:52PM -0700, Joseph Brenner wrote: > There's this much: > > https://docs.raku.org/language/variables#index-entry-$$CIRCUMFLEX_ACCENT > > > If you have self-declared a parameter using $^a once, you may refer to it > > using only $a thereafter. > > But it doesn't go

Re: callbacks with placeholder vars

2021-08-09 Thread Joseph Brenner
There's this much: https://docs.raku.org/language/variables#index-entry-$$CIRCUMFLEX_ACCENT > If you have self-declared a parameter using $^a once, you may refer to it > using only $a thereafter. But it doesn't go anywhere near far enough. You *had better* to refer to it as $a or you'll get

Re: callbacks with placeholder vars

2021-08-09 Thread Joseph Brenner
Okay, so my central confusion here has to do with not understanding that the caret gets used *only once* in a construct like this: my $cb = { do if ($^a eq $^b) { "$a"; } else { "$a & $b"; } }; say $cb( 'a', 'b' ); After $^a is

callbacks with placeholder vars

2021-08-09 Thread Joseph Brenner
Here's a simple use of a callback that just works: my $cb = { "$^a & $^b"; }; say $cb('a', 'b'); # a & b Just as an aside, it's interesting that this would be an error: say $cb('a', 'b', 'c'); # Too many positionals passed; expected 2 arguments but got 3 The