Questions tagged [rakudo]

Rakudo is a compiler for the Raku programming language running on the MoarVM virtual machine.

Rakudo is a Raku compiler running on the MoarVM, JVM and JavaScript.

Related links

189 questions
9
votes
2 answers

Why can readonly array attributes on a Raku class be modified?

Why can readonly array attributes be modified on a Raku class, but on the other hand, scalars cannot be modified? How can I make @.baz "readonly"? class Boo { has $.bar; has @.baz; }; my $boo = Boo.new; $boo.baz = (1, 2); # works ... ? say…
Julio
  • 5,208
  • 1
  • 13
  • 42
9
votes
2 answers

Destructure a List of Pairs

Consider .say for (1,2,2).rotor(2=>-1).map( -> ($a, $b) { $a - $b }) which works as expected. However, .say for (1,2,2).pairs.rotor(2=>-1).map( -> ($a, $b) { $a.value - $b.value }) throws Too few positionals passed to ''; expected 2…
Holli
  • 5,072
  • 10
  • 27
9
votes
1 answer

Why does Raku crash with 'Abort trap: 6' while using Cro on a MacOS Catalina?

I'm using macOS Catalina and trying to execute a simple command raku -e "use Cro::HTTP::Route". I will get a message [1] 19228 abort raku in the Zsh shell or Abort trap: 6 in the Bash shell. I face the same issue when using an OpenSSL module like…
Mikhail Khorkov
  • 593
  • 2
  • 12
9
votes
4 answers

Concurrency, react-ing to more than one supply at a time

Please consider the code below. Why is the output of this is "BABABA" and not "AAABAA" / "AABAAAB"? Shouldn't the two supplies run in parallel and the whenever fire immedeatly when there is an event in any of them? my $i = 0; my $supply1 = supply {…
Holli
  • 5,072
  • 10
  • 27
9
votes
2 answers

Rakudo (Perl6): What are the features that don’t yet work?

Rakudo: Is there a place where all the features that don't yet work are listed?
sid_com
  • 24,137
  • 26
  • 96
  • 187
8
votes
2 answers

Why is my %h is List = 1,2; a valid assignment?

While finalizing my upcoming Raku Advent Calendar post on sigils, I decided to double-check my understanding of the type constraints that sigils create. The docs describe sigil type constraints with the table below: Based on this table (and my…
codesections
  • 8,900
  • 16
  • 50
8
votes
1 answer

What's the difference between $?CLASS and ::?CLASS

The Raku docs describe ::?CLASS as a compile-time variable that answers "Which class am I in?". Then, a couple of paragraphs later, it mentions $?CLASS, and says that it answers "Which class am I in? (as variable)". What's the difference between…
codesections
  • 8,900
  • 16
  • 50
8
votes
1 answer

EXPORTHOW and DECLARE - what are they?

I have read an article by Jonathan Worthington about meta programming. There he writes: Do do this, we stick it in the EXPORTHOW module, under the name “class”. The importer pays special attention to this module, if it exists. At he same time here…
hasrthur
  • 1,410
  • 15
  • 31
8
votes
6 answers

Calling a module does not work in Raku in Windows

I have two files main.raku and TestMod.rakumod in a directory C:\Users\suman. TestMod.rakumod unit module TestMod; sub add($a, $b) is export { $a + $b } main.raku use lib $*PROGRAM.dirname; use TestMod; say add(8,9) I want to call some…
Suman Khanal
  • 3,079
  • 1
  • 17
  • 29
8
votes
1 answer

Summing list of lists in Raku

I am trying to sum a list of lists in Raku. Example taken from here: my $arr = ([1e50, 1, -1e50] xx 1000); say (flat |$arr).sum; # output 0 # https://docs.raku.org/language/operators#infix_xx # https://docs.raku.org/routine/flat It outputs 0…
Suman Khanal
  • 3,079
  • 1
  • 17
  • 29
8
votes
1 answer

Can I copy a function with its *current* state?

Raku's state declarator can be used to give a subroutine or other block its own local state that persists across multiple invocations of the function: sub f { state $n++ } say f; # OUTPUT: «0» say f; # OUTPUT: «1» say f; # OUTPUT: «2» I'm aware of…
codesections
  • 8,900
  • 16
  • 50
8
votes
1 answer

Confusing .fmt behavior with nested Lists

The docs say that fmt Returns a string where each element in the list has been formatted according to $format [the first argument] and where each element is separated by $separator [the second argument]. Based on that description, I expected to be…
codesections
  • 8,900
  • 16
  • 50
8
votes
2 answers

Does the `do` keyword run a block or treat it as an expression?

The docs state that "The simplest way to run a block where it cannot be a stand-alone statement is by writing do before it" and provide the following example: # This dies half of the time do { say "Heads I win, tails I die."; Bool.pick } or die;…
codesections
  • 8,900
  • 16
  • 50
8
votes
1 answer

Unexpected Non-Laziness

I wrote this code for this weeks challenge to produce ugly numbers. sub factors( $n ) { if $n > 1 { $_, |factors $n div $_ given ( grep $n %% *, 2..* ).first } } .say for ( 1, |grep *.&factors.all ∈ ( 2, 3, 5 ), 2..* )[^150]; This…
Holli
  • 5,072
  • 10
  • 27
8
votes
1 answer

Sequence of Raku program compilation and execution (maybe nested compile phases?)

The following program correctly fails to compile: sub f(Int $a) { my Str $b = $a } say f 42; say f 'foo'; Specifically, line 3 causes a compilation error (with a ===SORRY!=== error message); this error occurs before line 2 is executed, so the type…
codesections
  • 8,900
  • 16
  • 50