Questions tagged [raku]

For questions relating to the Raku programming language (formerly known as Perl 6).

Raku

Raku is an expressive and feature-rich programming language designed by Larry Wall and developed by the community.

Features include:

  • Object-oriented programming
  • Functional programming primitives
  • Parallelism
  • Concurrency
  • Asynchrony
  • Definable grammars for pattern matching and generalized string processing
  • Optional and gradual typing
  • Extensive Unicode support from code points to grapheme clusters
  • Multiple dispatch
  • Introspection
  • Rational numbers

is a Raku implementation that targets multiple back ends.

The MoarVM back end is recommended for normal use, but back ends for the Java Virtual Machine and JavaScript are also under active development.

The Rakudo implementation shipped a first official release named “коледа” on December 25, 2015. Most of the specification is frozen, and optimizations are ongoing.

Official links

1993 questions
13
votes
3 answers

How do you make HTTP requests with Raku?

How do you make HTTP requests with Raku? I'm looking for the equivalent of this Python code: import requests headers = {"User-Agent": "python"} url = "http://example.com/" payload = {"hello": "world"} res = requests.get(url, headers=headers) res =…
R891
  • 2,550
  • 4
  • 18
  • 30
13
votes
1 answer

What's the difference between $/ and $¢ in regex?

As the title indicates, what is the difference between $/ and $¢? They appear to always have the same value: my $text = "Hello world"; $text ~~ /(\w+) { say $/.raku } (\w+)/; $text ~~ /(\w+) { say $¢.raku } (\w+)/; Both result in Match objects…
user0721090601
  • 5,276
  • 24
  • 41
13
votes
3 answers

Mixing Private and Public Attributes and Accessors in Raku

#Private attribute example class C { has $!w; #private attribute multi method w { $!w } #getter method multi method w ( $_ ) { #setter method warn “Don’t go changing my…
librasteve
  • 6,832
  • 8
  • 30
13
votes
1 answer

Running a Raku Cro app as a persistent service

I'd like to run a perl6/raku Cro app as a service behind a frontend webserver. Just running cro run won't handle restarting after segfaults & reboots. Previously with perl5 I've used FastCGI - however Cro::HTTP::Server's…
fireartist
  • 165
  • 4
13
votes
3 answers

How to implement around in Raku

In Perl, using Moo, you can implement around subs, which will wrap around other methods in a class. around INSERT => sub { my $orig = shift; my $self = shift; print "Before the original sub\n"; my $rv = $orig->($self, @_); …
Tyil
  • 1,797
  • 9
  • 14
13
votes
1 answer

Expressing the double summation sequence in Raku

How to express the double variable double summation sequence in Perl 6? For an example of double variable double summation sequence see this It must be expressed as is, i.e. without mathematically reducing the double summation into a single…
Lars Malmsteen
  • 738
  • 4
  • 23
13
votes
1 answer

Raku (née Perl 6) reduce function and reduction metaoperator give different results

my @s=<1 2 3 2 3 4>; say reduce {$^a < $^b}, @s; say [<] @s; # -------- # True # False My question is two fold: Firstly, why does the reduction metaoperator processes the < operator differently? It looks like the reduction metaop is estimatedly…
Terry
  • 1,206
  • 1
  • 10
  • 26
13
votes
2 answers

list return from Inline::Perl5 gives a count of items, not the list

Some simple Inline::Perl5 code returns a list, but it seems to return the count of the items rather than the actual list. Changing the number of items involved changes the count. use Inline::Perl5; my $p5…
Joseph Brenner
  • 664
  • 3
  • 14
13
votes
1 answer

Why does :{} create a "Hash[Mu,Any]" object (and what is it and how does it compare to a normal "Hash")?

At first, I simply wondered why there was a colon before the empty braces in line 2 of this code (from the Perl 6 Advent Calendar, December 25, 2018)? sub is-happy( $n is copy ) { my $seen-numbers = :{}; while $n > 1 { return False…
Christopher Bottoms
  • 11,218
  • 8
  • 50
  • 99
13
votes
2 answers

Can you write Perl 6 scripts using an encoding that is not utf8?

Perl 5 has the encoding pragma or the Filter::Encoding module, however, I have not found anything similar in Perl 6. I guess eventually source filters will be created, but for the time being, can you use other encodings in Perl 6 scripts?
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
13
votes
3 answers

How to get all the signatures of multi sub or build-ins?

I defined a multi sub which has two signatures: multi sub mie(Str $s, Int $i) { $s x $i } multi sub mie(Int $s, Int $i) { ... } say &mie.signature; # ;; Mu | is raw) I want to get the signature of this multi sub, but the above result is not what i…
chenyf
  • 5,048
  • 1
  • 12
  • 35
13
votes
2 answers

How to call Perl 6 from Java?

Perl 6 regexes/grammars are much better structured, more powerful and readable than Perl 5 or related Perl compatible regexes everywhere, including regexes in Java. I am looking for a way to execute Perl 6 code with that regex/grammar code from…
13
votes
1 answer

Why don't new operator definitions persist in the Perl 6 REPL?

I was having issues experimenting with defining operators on the Perl 6 REPL, and noticed that they do work, but only when used on the same line as they are defined. Why is this the case? > sub postfix:(Int $x where { $x >= 0 }) { [*] 1..$x };…
13
votes
1 answer

Double junction arguments swapping sides

I'm confused about how double junctions are supposed to work. This makes some sense: say all('a', 'b', 'c') ~ any('d', 'e'); gives all(any(ad, ae), any(bd, be), any(cd, ce)) This doesn't make sense: say any('a', 'b', 'c') ~ all('d',…
13
votes
2 answers

Can a shared supply run multiple tap blocks simultaneously?

Consider this code where a tap takes awhile to complete. All the blocks are running simultaneously (immediately outputting) then sleeping. Most don't finish because the program ends sooner then they do: my $supply = Supply.interval(0.2); my $tap =…
brian d foy
  • 129,424
  • 31
  • 207
  • 592