News for hackers. Stuff that matters.
Re:Why Would Anyone Use Perl 6? by viraptor on Wednesday January 13, 2016 @06:56AM (#10893672)
Is this just standard sets, like python's:

    In [1]: {3,4,5} & {5,6}
    Out[1]: {5}
or is there something I'm missing?
Re:Why Would Anyone Use Perl 6? by awwaiid on Wednesday January 13, 2016 @08:13AM (#10893987)
The | junctions seem a lot like sets to me, though I guess there is a lot of fancy you can use. One that comes to mind is that you can pretend that it is a single value, even if it is a complex junction of & and | things:

    > (5|4) + 1
    any(6, 5)
    > (5&4) + 1
    all(6, 5)
    > my $x = 5|4|3|2
    any(5, 4, 3, 2)
    > say "yep!" if $x + 2 ~~ 7
    yep!
    > ((2|3|4|5|6|7) & (3|4)) + 1 ~~ 5
    True
    > ((2|3|4|5|6|7) & (3|4)) + 1 ~~ 6
    False
Kinda weird, especially & junctions. The docs[1] say "Junctions are meant to be used as matchers in boolean context; introspection of junctions is not supported. If you feel the urge to introspect a junction, use a Set or a related type instead."

So far in my Perl 6 exploration I don't think I've used/needed junctions -- strikes me as a specific sort of use-case, but maybe familiarity would help me spot more (useful) opportunities.

[1] http://doc.perl6.org/type/Junction, though like all P6 docs needs more contributions

Re:Why Would Anyone Use Perl 6? by akavi on Wednesday January 13, 2016 @10:25AM (#10894936)
If I understand correctly, it's a nice literal syntax for a vector/set hybrid data structure?

If you wanted, you could get pretty close in ruby with only a sprinkle of ill-advised metaprogramming.

    > junc{5|4} + 1
    any(6, 5)
    > junc{5&4} + 1
    all(6, 5)
    > x = junc{5|4|3|2}
    any(5, 4, 3, 2)
    > puts "yep!" if x + 2 =~ 7
    yep!
    > junc{(2|3|4|5|6|7) & (3|4)} + 1 =~ 5
    True
    > junc{(2|3|4|5|6|7) & (3|4)} + 1 =~ 6
    False
would be possible.

I guess I'm just curious if this is a situation that comes up often enough to need a built in literal syntax.

Re:Why Would Anyone Use Perl 6? by hahainternet on Wednesday January 13, 2016 @07:59AM (#10893933)
It's not standard sets, it's a bit more than that, Perl 6 has sets of course, but Junctions should be able to autothread and express a sort of superposition of values.

http://doc.perl6.org/type/Junction

I could copy and paste the definition but it wouldn't be too helpful without context.

Re:Why Would Anyone Use Perl 6? by arethuza on Wednesday January 13, 2016 @08:06AM (#10893957)
So like software SIMD?

When it says autothread does it mean actual separate threads/CPUs?

Re:Why Would Anyone Use Perl 6? by hahainternet on Wednesday January 13, 2016 @08:11AM (#10893974)
It's not so much SIMD. Perl 6 has a number of different constructs in which multiple operations can be carried out like that. However, yes the intention is to enable a large number of these scenarios to be carried out on multiple CPUs.

I don't think Rakudo implements that yet, but there's quite a lot to improve first.