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
1 answer

Is there a way to get a list of all known types in a Perl 6 program?

Is there a way to get a list of all known types (builtin, defined, loaded, whatever) a Perl 6 program knows about? I don't have a particular task in mind, and this is a bit different than figuring out if a type I already know about has been defined.
brian d foy
  • 129,424
  • 31
  • 207
  • 592
13
votes
2 answers

How can I return context sensitive return values in Perl 6?

In the summary of differences between Perl 5 and Perl 6, it is noted that the wantarray function is gone: wantarray() is gone wantarray is gone. In Perl 6, context flows outwards, which means that a routine does not know which context it is…
Eric Strom
  • 39,821
  • 2
  • 80
  • 152
13
votes
2 answers

Does Perl6 support dependent types?

I was recently looking at the wikipedia page for dependent types, and I was wondering; does Perl 6 actually introduce dependent types? I can't seem to find a reliable source claiming that. It might be obvious to some, but it sure as heck ain't…
hao ramirez
  • 235
  • 1
  • 6
12
votes
7 answers

Is it a design flaw that Perl subs aren't lexically scoped?

{ sub a { print 1; } } a; A bug,is it? a should not be available from outside. Does it work in Perl 6*? * Sorry I don't have installed it yet.
new_perl
  • 7,345
  • 11
  • 42
  • 72
12
votes
1 answer

Understanding Cro request/response cycle and memory use

I'm a bit confused about how Cro handles client requests and, specifically, why some requests seem to cause Cro's memory usage to balloon. A minimal example of this shows up in the literal "Hello world!" Cro server. use Cro::HTTP::Router; use…
codesections
  • 8,900
  • 16
  • 50
12
votes
2 answers

How can I use EVAL to pass arguments to subroutines?

I'm experimenting with Raku and trying to figure out how I might write a program with subcommands. When I run, ./this_program blah: #! /usr/bin/env raku use v6; sub MAIN($cmd, *@subcommands) { $cmd.EVAL; } sub blah() { say 'running blah';…
StevieD
  • 6,925
  • 2
  • 25
  • 45
12
votes
2 answers

Getting "value without a container" error

Got this: for $config.IO.slurp.lines <-> $l { $l .= trim; ... } Get this: t/01-basic.rakutest ..3/5 Parameter '$l' expects a writable container (variable) as an argument, but got '# karabiner config file' (Str) as a value without a container. …
StevieD
  • 6,925
  • 2
  • 25
  • 45
12
votes
1 answer

Why can't I iterate after an assignment in Raku?

Given the following code, it seems that I cannot iterate over a Buf if it had been assigned to a variable, unless I cast it to a list, even though it's not a lazy sequence. What gives? my $file = open $path, bin => True; $_.chr.say for…
marwy
  • 177
  • 6
12
votes
1 answer

Immutable (uncontainerized) elements in arrays created by deepmap

If I understand the Raku docs correctly, the elements of Arrays are always containerized, i.e. Scalars. However, the deepmap method seems to create (inner) Arrays with uncontainerized elements: my @a = [1, [2, 3]]; my @b = @a.deepmap: *.clone; say…
Nikola Benes
  • 2,372
  • 1
  • 20
  • 33
12
votes
1 answer

Understanding the point of supply blocks (on-demand supplies)

I'm having trouble getting my head around the purpose of supply {…} blocks/the on-demand supplies that they create. Live supplies (that is, the types that come from a Supplier and get new values whenever that Supplier emits a value) make sense to me…
codesections
  • 8,900
  • 16
  • 50
12
votes
1 answer

Can Raku OO help me avoid integration layer boilerplate

I so enjoy the low boilerplate of raku OO that I am a little surprised that I cannot shake off some integration layer boilerplate. Here is what I have working today (somewhat golfed): class Error { has Real $.absolute; method percent(…
librasteve
  • 6,832
  • 8
  • 30
12
votes
1 answer

How to evaluate eagerly a sequence coming from grep in Raku?

I don't understand how laziness / eagerness works in Raku. More precisely how to force eagerness. I get that Infinite List are lazy. What I don't understand is that some List that have an end are lazy, and why the eager method doesn't work in my…
WhiteMist
  • 885
  • 4
  • 13
12
votes
3 answers

Raku Cro service subscribing to data "in the background" general guidance

I am attempting to put together a Cro service that has a react/whenever block consuming data "in the background" So unlike many examples of websocket usage with Cro, this has nothing to do with routes that may be accessed via the browser. My use…
camstuart
  • 623
  • 3
  • 13
12
votes
1 answer

Why do different ways of calling Raku result in very different startup times?

I have v2020.12 of Rakudo installed on my computer and have also built v2020.12 from source. When profiling startup times, I noticed the following results: (these benchmarks use hyperfine, but I also got similar results with time). $ which…
codesections
  • 8,900
  • 16
  • 50
12
votes
1 answer

Is it possible to define a new operator in Raku and control its precedence?

Consider this new operator: sub infix:<*++>(\num1, \num2) { num1 * num2 + 1 } say (2 + 1 *++ 3); This code prints: 10 However, is it possible to control the precedence? Such it behaves like this: say (2 + (1 *++ 3)) without needing to use…
Julio
  • 5,208
  • 1
  • 13
  • 42