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

Warnings while building Rakudo in Windows

I followed the instructions for building Rakudo here. With similar reading here and here, I tried building it in Windows with VS-2019. However, while building Rakudo in windows I get the following build warnings: Updating submodules…
Suman Khanal
  • 3,079
  • 1
  • 17
  • 29
5
votes
1 answer

How can I insert some route-checking middleware in Cro?

Say I need to check some URI before I serve some result. I can do something like this: sub type-routes { route { get -> Str $type where $type ∈ @food-types { my %ingredients-table = $rrr.calories-table; my @result…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

Convert a string to list of hexadecimal of each byte (Raku)

FAQ: In Raku, how to convert a string to the list of its bytes hexadecimal from (i.e. hex decoder) Currently, I have: say "I ❤ ".encode.list.map(*.base(16)); # (49 20 E2 9D A4 20 F0 9F A6 8B) Which is 4 operations
Tinmarino
  • 3,693
  • 24
  • 33
5
votes
2 answers

Parse from String and convert to float, integer (Raku)

FAQ: In Raku, how do I parse a String and get a Number ? For example: xxx("42"); # 42 (Int) xxx("0x42"); # 66 (Int) xxx("42.123456789123456789"); # 42.123456789123456789 (Rat) xxx("42.4e2"); # 4240 (Rat) xxx("42.4e-2"); # 0.424 (Rat)
Tinmarino
  • 3,693
  • 24
  • 33
5
votes
2 answers

Named regex fails capture in raku

Could someone explain why captures (named and un-named) don't seem to work in named regexes? I'm expecting that It is something I'm doing wrong, but if so, I don't see it. Here is captured text from the raku repl as my short-form example. > my $s =…
hsmyers
  • 665
  • 7
  • 10
5
votes
1 answer

Trying to recast $*ARGFILES

In order to fix this error I would need to re-cast $*ARGFILES as a IO::CatHandle, since it uses some attributes of that class. I'm trying this: use IO::CatHandle::AutoLines; # -*- mode:perl6 -*- use Test; if $*ARGFILES === $*IN { $*ARGFILES =…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
0 answers

Make sure email is stored as a string [Raku]

Not sure how to close this, but I can no longer delete it either... The issue is resolved I have a form where users input an email and CRO tries to query the email in an accounts database to find a match. The problem is that Sqlite3 sees the @…
3leggedquid
  • 67
  • 1
  • 4
5
votes
1 answer

More than enough "Always succeed"? [ RAKU ]

In the documentation of Grammars under Section : "Always succeed" assertion I reproduced the example presented there, with added code to show the table produced, in each stage of the parsing mechanism : use v6.d; grammar Digifier { rule TOP…
jakar
  • 1,701
  • 5
  • 14
5
votes
1 answer

"Nothing" in Lookaround terms [RAKU]

I was reading in regexes documemtation about "Tilde for nesting structures". The sideline explanation about the use of is: Here successfully matches the null string. I assumed that I was able to use instead of it, but it failed to do…
jakar
  • 1,701
  • 5
  • 14
5
votes
2 answers

Overloading operators for objects that are used to instantiate parameterized roles

In C++ you can create templated classes that use a particular operator on the templated objects and the class from which these objects are instantiated must overload that particular operator for its objects to work with the templated class. For…
uzluisf
  • 2,586
  • 1
  • 9
  • 27
5
votes
1 answer

"Too few positionals passed" in arg-less method with type captures

In this script: role Capturer { method capturing(::CLASS:D: $ ) { say "Working with ", $?CLASS, " that holds ", $.gist; } } ( <1 2 3 4> but Capturer ).capturing(); A arg-less method is defined, capturing, but if I call it this…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

Error "emit without supply or react" when tapping IO::Notifications

These nested supplies cause an error, but apparently only if the internal supply is IO::Notification. It does not seem to be a problem for any other supply: my $supply = IO::Notification.watch-path( "/var/log/syslog" ); my $parsed = supply { …
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

Unsinking sunk calls via CALL-ME

While trying to come up with an example of maps in sunk context, I bumped into this code: my $a = -> { 42 }; my $b = -> { "foo" }; $a; $a(); ($a,$b).map: { $_ }; The first call to $a by itself returns: WARNINGS for…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

"Illegally post-declared types" with circular class definition

Rakudo version 2020.01 This does not compile. use v6; class N1 {} class T1 {} class G1 { has @.g is required where A1|Q1; } class Q1 { has $.q is required where N1|T1|G1; } class A1 { has Q1 @.a is required; } ===SORRY!=== Error…
daxim
  • 39,270
  • 4
  • 65
  • 132
5
votes
1 answer

How to use matching delimiters in Raku

I'm trying to write a token that allows nested content with matching delimiters. Where (AB) should result in a match to at least "AB" if not "(AB)". And (A(c)B) would return two matches "(A(c)B)" and so on. Code boiled down from its…
hsmyers
  • 665
  • 7
  • 10