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
17
votes
3 answers

Idiomatic way to implement standard Unix behaviour of using STDIN if no files are specified on the command line?

Is there a more elegant way of processing input coming from either the command line arguments or STDIN if no files were given on the command line? I'm currently doing it like this: sub MAIN(*@opt-files, Bool :$debug, ... other named options ...) { …
VZ.
  • 21,740
  • 3
  • 39
  • 42
17
votes
3 answers

What is the meaning of (Any) in Raku - specifically the ()?

Here is an experiment with Raku: > my $x (Any) > my $y=1 1 > my @a=[1, 2] [1 2] > my %h=a=>'b' {a => b} > say "nil" unless $x nil I can see that [] indicates an array literal, {} a hash literal. I can also see that (Any) behaves like nil -…
Ross Attrill
  • 2,594
  • 1
  • 22
  • 31
17
votes
1 answer

How can you call JavaScript builtins from Perl 6 with the new JS backend?

I know it is possible to invoke Java when Perl 6 is using that backend: How do I invoke a Java method from perl6 Is there a way yet to access e.g. the JavaScript DOM interface from Perl 6 with the new Rakudo JavaScript VM running in the…
S. Albano
  • 707
  • 7
  • 21
17
votes
3 answers

Is it possible to compile/install Perl6 on a Raspberry Pi 3?

I am trying to install Rakudo Star 2018.04 on a Raspberry Pi 3. I do: sudo perl Configure.pl --gen-moar --gen-nqp --prefix ~/rakudo and it completes successfully. And then I try: sudo make-install but it fails with: The following step can take a…
ryn1x
  • 1,052
  • 2
  • 8
  • 19
17
votes
3 answers

Accessing the last element in Perl6

Could someone explain why this accesses the last element in Perl 6 @array[*-1] and why we need the asterisk *? Isn't it more logical to do something like this: @array[-1]
smith
  • 3,232
  • 26
  • 55
17
votes
1 answer

Deploying self contained Perl 6 script

What is the best strategy to deploy a Perl 6 script which use external modules like LWP::Simple? For example in Perl we have PAR. Is there are an option in Perl 6 to deploy a self contained script that the user need only to run without bothering…
smith
  • 3,232
  • 26
  • 55
16
votes
3 answers

Raku slow Mixes sorting

Update On the same computer, using the Rakudo compiler "rakudo-moar-2021.06-01-macos-x86_64-clang.tar" I get 3-10 times speed-ups compared to the timings of my calculations in the original post. .elems: 100000 .head(3): (id.20444 =>…
Anton Antonov
  • 726
  • 4
  • 11
16
votes
2 answers

Negated Named Regex, or Character Class Interpolation in Raku

I'm trying to parse a quoted string. Something like this: say '"in quotes"' ~~ / '"' <-[ " ]> * '"'/; (From https://docs.raku.org/language/regexes "Enumerated character classes and ranges") But... I want more that one type of quote. Something like…
JustThisGuy
  • 1,109
  • 5
  • 10
16
votes
8 answers

Remove some characters from a string by index (Raku)

FAQ: In Raku, how do you remove some characters from a string, based on their index? Say I want to remove indices 1 to 3 and 8 xxx("0123456789", (1..3, 8).flat); # 045679
Tinmarino
  • 3,693
  • 24
  • 33
16
votes
2 answers

I can call any method on Nil and this feels wrong

I spent considerable time debugging a script recently, and when I finally found the problem it was because of code that looked like this: class Foo { has $.bar; method () { # do stuff $!.bar; } } It turned out the…
jja
  • 2,058
  • 14
  • 27
16
votes
2 answers

Perl6 search then replace with output of subroutine

I've combed the docs but I can't seem to find how to do this in perl6. In perl5 I would have done (just an example): sub func { ... } $str =~ s/needle/func($1)/e; i.e. to replace 'needle' with the output of a call to 'func'
iPherian
  • 908
  • 15
  • 38
16
votes
1 answer

Why is adding methods to a type different than adding a sub or an operator in perl6?

Making subs/procedures available for reuse is one core function of modules, and I would argue that it is the fundamental way how a language can be composable and therefore efficient with programmer time: if you create a type in your module, I can…
16
votes
1 answer

Why are the source file names not human readable?

I installed Perl6 with rakudobrew and wanded to browse the installed files to see a list of hex-filenames in ~/.rakudobrew/moar-2018.08/install/share/perl6/site/sources as well as ~/.rakudobrew/moar-2018.08/install/share/perl6/sources/. E.g. > ls…
matthias krull
  • 4,389
  • 3
  • 34
  • 54
16
votes
3 answers

How to execute an external command and capture its output in perl6?

How can I execute an external command and capture its output in Perl6? Perl5-style back-ticks don't seem to work: > my $results = `ls`; Confused at line 1, near "my $results" Synopsis 16 documents the run method, but this returns the exit status…
mattbh
  • 5,230
  • 2
  • 27
  • 27
16
votes
4 answers

Does Perl6 support something equivalent to Perl5's __DATA__ and __END__ sections?

Does perl6/Rakudo have something equivalent to perl5's __DATA__ or __END__ sections?
sid_com
  • 24,137
  • 26
  • 96
  • 187