> but what's that cabbage thing before $c?

It's the Atomic Symbol, U+269B. (Tangent: when looking up that unicode value, I 
learned
that Unicode puts the atomic symbol in the Religious Symbols subcatigory. 
Slightly troubling!)

Here, it's being used as part of the atomic prefix increment operator,
https://docs.raku.org/type/atomicint#prefix_++⚛ (As Vadim already mentioned).

That operator is exactly like the regular prefix ++, except that it's 
guaranteed to avoid 
race conditions in multithreaded use.  It's appropriate to use with Junctions, 
because they're
theoretically multitheadable.  On the other hand, they *aren't* yet 
multithreaded in any 
implementation, so for now

    my $c = 0;
    sub foo($) { ++$c }('a'|'b,b'|'c');
    say $c;

works just as well (though the semantics are technically wrong!)

> Also worth noting that the hyper-op is needed here because pointy blocks are 
> not auto-threaded
> over junctions and take them as-is

Interesting – I didn't realize that.  Is the hyper op the only thing that 
triggers auto-threading
for Blocks?

Here's a slightly different take on the same basic idea, which avoids leaking 
$c:

    {my atomicint $len; sub ($) { ++⚛$len }($_); $len}('a'|'b,b'|'c')





May 24, 2021 10:11 AM, "Andy Bach" <andy_b...@wiwb.uscourts.gov> wrote:

> my atomicint $c = 0;
> sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
> say $c;
> 
> I was sort of hanging on by my fingertips (this completely lost me:
> 
>> Or, taking about tricks:
> 
> ('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });
> 
> ) but what's that cabbage thing before $c? Oh, and WAT is" Weird/will Ass 
> Thing"?
> 
> _______________________________
> 
> From: Vadim Belman <vr...@lflat.org>
> Sent: Monday, May 24, 2021 8:53 AM
> To: perl6-users <perl6-us...@perl.org>
> Subject: Re: File::Find using a junction with exclude
> CAUTION - EXTERNAL:
> 
> Still ugly but much more reliable trick would be to use a sub and a counter 
> variable:
> 
> my atomicint $c = 0;
> sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
> say $c;
> 
> Or, taking about tricks:
> 
> ('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });
> 
> Apparently, this one is not ugly by semantics, but by its notation too. Also 
> worth noting that the
> hyper-op is needed here because pointy blocks are not auto-threaded over 
> junctions and take them
> as-is:
> 
> -> $v { say $v.WHAT }(1|2); # (Junction)
> 
> Best regards,
> Vadim Belman
> 
>> On May 24, 2021, at 8:42 AM, Daniel Sockwell <dan...@codesections.com> wrote:
> 
> It can be done without the EVAL:
> 
> any('a', 'b', 'c').raku.substr(4, *-1).split(',').elems
> 
> 3
>> Yeah, but only at the cost of some fragility:
> 
> any('a', 'b,b', 'c').raku.substr(4, *-1).split(',').elems
>> 4
>> 
>> I suppose you could do:
> 
> any('a', 'b,b', 'c').elems.raku.substr(4, *-1).split(',').elems
>> 3
>> 
>> but I'm not sure that's _that_ much better than EVAL – either way, we're 
>> depending on the Str
>> representation of inherently non-Str data, which seems like the main sin of 
>> EVAL.
>> 
>> – codesections
> 
> CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. 
> Exercise caution when
> opening attachments or clicking on links.

Reply via email to