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

Implementing an infinite list of consecutive integers in Lisp for lazy evaluation

Prelude In Raku there's a notion called infinite list AKA lazy list which is defined and used like: my @inf = (1,2,3 ... Inf); for @inf { say $_; exit if $_ == 7 } # => OUTPUT 1 2 3 4 5 6 7 I'd like to implement this sort of thing in…
5
votes
2 answers

Raku NativeCall to LibX11 screen and display

Fedora 33 Raku I am trying to use Raku's NativeCall to talk to libX11.so to print out both my screen and my display: use NativeCall; class Display is repr('CStruct') { has Pointer $.DisplayPtr }; # libX11.so --> X11 sub XOpenDisplay(Str $name =…
Todd
  • 976
  • 4
  • 10
5
votes
1 answer

Reduction operator using user-defined function error

The raku webpage says that extra bracket should be used for user-defined functions within reduction operator: https://docs.raku.org/language/operators#Reduction_metaoperators However, I am getting errors when I pass the function as a variable (I am…
lisprogtor
  • 5,677
  • 11
  • 17
5
votes
1 answer

Raku: Installation of Termbox on Windows

Installation of the Raku module «Termbox» module fails on windows: Powershell> zef install Termbox Failed to find dependencies: python:from. I have installed Python (v3) on the pc, but that does not help. Is it possible to fix this, so that…
Arne Sommer
  • 570
  • 2
  • 8
5
votes
2 answers

Raku: Installation of Gnome::Gtk3 on Windows

I am trying to install the Raku module «Gnome::Gtk3» module on a Windows pc, without success. Powershell> zef install Gnome::Gtk3 This fails with a lot of "Cannot locate native library"-messages. I have installed Raku with choco, along with git.…
Arne Sommer
  • 570
  • 2
  • 8
5
votes
1 answer

Raku: Using topic variable (from a 'for') inside a regex

I have this code that works as expected: my @words = 'foo', 'bar'; my $text = 'barfoo'; for @words -> $to-regex { $text ~~ m/ ($to-regex) {say "matched $0"}/; } It prints: matched foo matched bar However, if I try to use topic variable on the…
Julio
  • 5,208
  • 1
  • 13
  • 42
5
votes
1 answer

Access resources for a different distribution

%*RESOURCES as a dynamic variable gives you access to every one of the Distribution::Resource objects within a specific distribution. These objects are installed along with it, so they're just there, available. However, I can't find a documented,…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

Can Raku guarantee that a pattern match is exhaustive (at compile time)?

Consider the following toy code: my $age-check = do given 18 { when $_ > 18 { 'old enough' } when $_ < 18 { 'too young' } }; say "The user is $age-check" # OUTPUT: «The user is False» This code contains a bug (not handling the case…
codesections
  • 8,900
  • 16
  • 50
5
votes
1 answer

Comma: "No test source roots in the project: is it properly configured?"

Comma 2020.07 (community edition) has changed the test configuration, and now you can test different things: module, project and so on. However, I can't simply get it to run the usual tests. When I use "All in project" testing, I get this error: No…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

It is possible to write NQP's precedence parser in Raku

I'm trying to figure out how I can rewrite NQP's Precedence Parser in Raku : The Precedence Parser is implemented here: https://github.com/Raku/nqp/blob/master/src/HLL/Grammar.nqp#L384 NQP should be a subset of Raku but the Grammar part seems to be…
Konrad Eisele
  • 3,088
  • 20
  • 35
5
votes
1 answer

Is it possible to access static methods and attributes outside the class in Raku?

In raku it seems possible to define static methods (via sub keyword) and static attributes (via my) Those can be referenced inside the same class. However, is it possible to access those methods and attributes outside of the class? Something similar…
Julio
  • 5,208
  • 1
  • 13
  • 42
5
votes
1 answer

Raku mode for xemacs?

I'm using Xemacs (not GNU Emacs) for ages, as I like it's interface better (and in days of yore, it's support for LaTeX/BibTeX and related tools was much better). But there seems to be no official Raku (neé Perl 6) mode around. There is one for GNU…
vonbrand
  • 11,412
  • 8
  • 32
  • 52
5
votes
2 answers

When does .race or .hyper outperform non-data-parallelized versions?

I have this code: # Grab Nutrients.csv from https://data.nal.usda.gov/dataset/usda-branded-food-products-database/resource/c929dc84-1516-4ac7-bbb8-c0c191ca8cec my @nutrients = "/path/to/Nutrients.csv".IO.lines; for @nutrients.race { my @data =…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
2 answers

Alter how arguments are processed before they're passed to sub MAIN

Given the documentation and the comments on an earlier question, by request I've made a minimal reproducible example that demonstrates a difference between these two statements: my %*SUB-MAIN-OPTS =…
acw
  • 447
  • 2
  • 9
5
votes
1 answer

Why does direct binding of an `our &foo` not work, but indirecting via a dynamic lookup does?

Why is there a difference between r1 and r2 when called outside of module TEST? module TEST { our &r1 := OUR::{'&r1'} := sub { say 'routine 1' } r1(); # routine 1 our &r2 := sub { say 'routine 2' } …
jakar
  • 1,701
  • 5
  • 14