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

Could not find List::Util

I'm trying to compile some raku code I saw on https://replit.com/languages/raku. The code is from Why is Raku reporting "two terms in a row" when I define a new operator?. It begins like this: unit module Format; use List::Util; ... It fails to…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
5
votes
1 answer

"No single root directory found, all dists must extract to a single directory" error when trying to upload module to zef via App::Mi6

Getting a weird error I've never seen before while trying to upload a new module to zef using the App::Mi6 mi6 release command: ==> Step 9. UploadToZef Are you sure you want to upload Directory-0.0.1.tar.gz to Zef ecosystem? (y/N) y Executing…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

Any way to easily ensure zef is pulling latest versions of raku modules?

I recently filed an issue here about zef downloading a stale version of a module, NativeHelpers::Callback which was failing when I tried to install it with zef install NativeHelpers::Callback. I had to clone the module to my local machine from…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

How does one use SQLite in Perl 6?

I want to start dabbling in Perl 6. A large percentage of my programming involves SQLite databases. It looks like work has been put into using SQLite in Perl 6, but most of the info I can find is old and vague. I see a "perl6-sqlite" module here,…
glibdud
  • 7,550
  • 4
  • 27
  • 37
5
votes
1 answer

Why aren't variables interpolated in `constant` declarations?

use v6.d; my Str $foo = 'Hello'; my constant $BAR = "--$foo--"; say $BAR; OUTPUT: Use of uninitialized value element of type Str in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. in…
Jim Bollinger
  • 1,671
  • 1
  • 13
5
votes
2 answers

Shouldn't the same srand value produce the same random numbers?

When I repeatedly run this code, srand 1; my @x = (1..1000).pick: 100; say sum @x; I get different answers each time. If I'm resetting with srand why shouldn't it produce the same random numbers each time? The error occurs in the REPL. The error…
Jim Bollinger
  • 1,671
  • 1
  • 13
5
votes
1 answer

How are dynamically scoped variables implemented in Rakudo/MoarVM?

That is, variables like $*scalar, @*array and %*hash. I'm asking this question mainly because I want to have an idea of how much of a burden they are on the overall performance of the grammar/regex engine. To add a bit of precision to my question, I…
WhiteMist
  • 885
  • 4
  • 13
5
votes
1 answer

Using scalar variables to refer to an array inside an explicit generator

I've written a code to calculate the Fibonacci series using array variables inside the explicit generator like this: my @fib = [0],[1],-> @a, @b {[|@a Z+ |@b]} ... Inf; say @fib[^6]; This works as expected. But when I use scalar variables inside…
Lars Malmsteen
  • 738
  • 4
  • 23
5
votes
3 answers

Why do these 2 for looping over sequences differ?

First: $ raku -e "for 1...6, 7...15 { .say }" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Now: $ raku -e "for 1...3, 7...15 { .say }" 1 2 3 7 11 15 I would expect this case to print 1,2,3,7,8,... 15. What's happening here?
zentrunix
  • 2,098
  • 12
  • 20
5
votes
0 answers

Unexpected argument processing by MAIN()

Scratching my head over this: multi sub MAIN(Str:D $arg, Bool :$switch, *@the-rest) { say $arg; say $switch; say @the-rest; } When called with: blah-command arg1 --switch It prints: arg1 (Bool) [--switch] I expected: arg1 True What…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

Proper way of avoiding deprecated code warning

I use CompUnit::PrecompilationStore::File in a module, which passes all my tests under Rakudo v2022.02 (on my local machine I have not yet upgraded Raku). Under Rakudo v2022.06, zef test . in the module directory causes a deprecation error (see…
Richard Hainsworth
  • 1,585
  • 7
  • 9
5
votes
1 answer

Is it possible to create subroutine signatures at run time?

I've got a method in a class: method options(*@opt) { if !@!valid-options { my $out = (cmd 'bin/md2html -h').out; my @matches = $out ~~ m:g/\s'--'(<-[\s]>+)/; for @matches -> $opt { …
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

MacOS: how to avoid ssl hell on intel mac with Raku?

Been having major problems today trying to get https://github.com/finanalyst/raku-pod-render installed. One of the big problems is tests failing that use ssl encryption.…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

How to deal with exceptions in IO::Socket::INET?

Assume there's no application listening at port 12340 in localhost. Shouldn't the command below print "error" ? $ raku -e "IO::Socket::INET.new(:host('localhost'), :port(12340)) or die 'error'" Could not connect socket: No connection could be made…
zentrunix
  • 2,098
  • 12
  • 20
5
votes
1 answer

Pushing elements to Buf

Shouldn't this just work ? use v6; my $data1 = Buf.new(1, 2, 3); my Buf $data2; my $n = $data1.bytes; for ^$n { my $ch = $data1.shift; $data2.push($ch) } I'm getting $ raku bufpush.raku Cannot resolve caller push(Buf:U: Int:D);…
zentrunix
  • 2,098
  • 12
  • 20