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
14
votes
2 answers

Web development using Raku

I want to know if web development can be done using Raku or Perl6? Like Django for Python, do we have any framework available for Raku? Id appreciate if you told us which are the libraries available or any tutorial. Are there any webhosting…
14
votes
2 answers

Why no "each" method on Perl6 sequences?

Sometimes I'll start writing a chain of method calls at the Perl 6 REPL, like: ".".IO.dir.grep(...).map(...). ...and then I realize that what I want to do with the final list is print every element on its own line. I would expect sequences to have…
Sean
  • 29,130
  • 4
  • 80
  • 105
14
votes
4 answers

Why/how is an additional variable needed in matching repeated arbitary character with capture groups?

I'm matching a sequence of a repeating arbitrary character, with a minimum length, using a perl6 regex. After reading through https://docs.perl6.org/language/regexes#Capture_numbers and tweaking the example given, I've come up with this code using…
drclaw
  • 2,463
  • 9
  • 23
14
votes
4 answers

Declare and initialize a typed array from a range

I recently tried my Array @a = 'a'..'z'; and my Array @a = @('a'..'z');. Both will produce the following error: Type check failed in assignment to @a; expected Array but got Str ("a") in block at line 1 However initializing…
Jessica Nowak
  • 849
  • 6
  • 13
14
votes
1 answer

proto token candidates ordering

How does perl6 decide which proto token to match against first? The below code works as expected, it matches the string 1234, and Grammar::Tracer shows that the first token matched against is s:sym, which makes sense since it's the longest…
hythm
  • 753
  • 1
  • 4
  • 12
14
votes
2 answers

perl6 placeholder variable and topic variable

There are both placeholder variables and topic variables in Perl 6. For example, the following two statements are the same say ( $_ * 2 for 3, 9 ); # use topic variables say ( { $^i * 2 } for 3, 9 ); # use placeholder…
John Z. Li
  • 1,893
  • 2
  • 12
  • 19
14
votes
2 answers

Overloading operators for a class

Let's say I have the following class: class A { has $.val; method Str { $!val ~ 'µ' } } # Is this the right way of doing it? multi infix:<~>(A:D $lhs, A:D $rhs) { ('(', $lhs.val, ',', $rhs.val, ')', 'µ').join; } How would I…
uzluisf
  • 2,586
  • 1
  • 9
  • 27
14
votes
1 answer

Why the performance difference in += vs +?

Debugging some code ended up testing the differences in the statements such as $counter=$counter + 1; vs $counter+=1; my $run=True; my $counter=0; my $sup=Supply.interval(1); my $tap= $sup.tap({ $run=$_ < 10; }); { while $run { …
drclaw
  • 2,463
  • 9
  • 23
14
votes
4 answers

How to die on undefined values?

I am attempting to work with a hash in Raku, but when I put some fake values into it (intentionally) like say %key; I get (Any) but I want the program to die in such occurrences, as Perl does, because this implies that important data is…
con
  • 5,767
  • 8
  • 33
  • 62
14
votes
2 answers

Perl 6: Backslashes in transliteration (tr///)

I noticed while experimenting with tr///, that it doesn't seem to translate backslashes, even when escaped. For example, say TR"\^/v"." given 'v^/\\'; say TR"\\^/v"." given 'v^/\\'; say TR"\ ^/v"." given 'v^/\\'; All of them output ...\ rather than…
Jo King
  • 590
  • 3
  • 17
14
votes
1 answer

How can you create Perl 6 REPL plugins?

Perl 6 comes with a REPL; and that REPL picks up plugins such as Linenoise as soon as it's installed, getting all the goodies. However, it's not clear to me how Linenoise plugs into the REPL to provide that functionality. I haven't seen it…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
14
votes
1 answer

Does Perl 6 automatically call any special methods when it cleans up an object?

I thought that Rakudo got finalizer support several years ago but I couldn't find the documentation for it (maybe it goes in Classes and Objects). Listing all the methods in a class didn't seem like the thing I was looking for. class Butterfly { …
brian d foy
  • 129,424
  • 31
  • 207
  • 592
14
votes
1 answer

perl6 signatures in POD

since --> is the preferred way to state the return type in a signature in perl6 I am wondering if or how it is possible to put the code of a function signature into C<...>. e.g. C Bool)>
Martin Barth
  • 796
  • 4
  • 13
14
votes
1 answer

Where did my Perl 6 operator go after I defined a more specific multi?

I'm playing with this little thing where a set can act as its complement by flipping around the tests. In order to make that work, I create special versions of the membership operators. class Complement { has $.set; } multi infix:<∈> ( $a,…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
14
votes
2 answers

Perl6: comparison operator ~~

I don't understand this behavior: > sort([1,2,3,4]) ~~ sort([1,2,3,4]) False Can you please explain it to me? Why these two lists (that are obviously equal) are not equal according to Perl 6. Update Interesting, but it depends on Perl6 version…
Igor Chubin
  • 61,765
  • 13
  • 122
  • 144