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

Unable to set attribute with bless method

Got a weird situation I think might be a bug. Not sure. But I have this: class Y { has Int $.vol; has Str $.quant; has Str $.abbr; submethod BUILD( Str :$!abbr, Int :$!vol, …
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

How to check if a program is present in the system with Raku?

I want to look if cmake is installed in my system with Raku. cmake --version at my command line gives: cmake version 3.23.0 CMake suite maintained and supported by Kitware (kitware.com/cmake). One way I know (not sure if it is right or there are…
Suman Khanal
  • 3,079
  • 1
  • 17
  • 29
5
votes
2 answers

Error while compiling regex function, why am I getting this issue?

My RAKU Code: sub comments { if ($DEBUG) { say "\n"; } my @filteredtitles = (); # This loops through each track for @tracks -> $title { ########################## # LAB 1 TASK 2 # …
Homerian
  • 183
  • 4
5
votes
1 answer

How can I avoid "not in ecosystem" errors thrown by comma IDE?

I have a test file in my module's t/ directory that does a use on a TestUtils files which has some variables and routines: use Test; use TestUtils; plan 4; check_cmd_output('No arguments'); check_cmd_output('Successfully ingested',…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
0 answers

Should Raku grammars or regexes be used for parsing wiki markup?

I need to convert a few hundred text files using TWiki markup to a more standard markup language (e.g. Markdown or Asciidoc) and, as there doesn't seem to be any usable tool for doing this (pandoc supports TWIki but very poorly, i.e. it…
VZ.
  • 21,740
  • 3
  • 39
  • 42
5
votes
1 answer

Is there a way to run an action on a grammar that's already been parsed?

If I do: my $parsed_grammar = PG.parse( $some_string ); Is there any way to to do something like the pseudo code below? $parsed_grammar.run_action( $action_class.new );
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

Grammar not parsing as expected with negative lookaround assertion

OK, this is either a bug or I'm going to look like a total idiot and I'm using a lookaround assertion completely wrong. I don't care about the latter so here we go. Got this grammar I'm testing: our grammar HC2 { token TOP { + } …
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
2 answers

Substitution in grammar action code throwing bizarre "P6opaque" error

I have this action which overrides an action in another action class: method taskwiki-prefix($/ is copy) { my $prefix = $/.Str; $prefix ~~ s:g!'|'!!; make $prefix; } The substitution throws this…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
2 answers

Alternate version of grammar not working as I'd prefer

This code parses $string as I'd like: #! /usr/bin/env raku my $string = q:to/END/; aaa bbb # this has trailing spaces which I want to keep kjkjsdf kjkdsf END grammar Markdown { token TOP { ^ ([ | ])+ $ } token…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
0 answers

What could happen if I don't put a `require Module` code in a BEGIN block?

Is there anything wrong with not putting the conditional module loading in a BEGIN block? Without the BEGIN block changing the environment variable after precompilation would still affect which module is loaded. my $table; #BEGIN { if %*ENV
sid_com
  • 24,137
  • 26
  • 96
  • 187
5
votes
0 answers

Rakudo Star bundle 2022.02 build failed

If this question should be in a more appropriate forum, please point me to it. Thanks. I am trying to upgrade to star bundle 2022.02 and it failed. I feel it is too hairy for me to try to tweak the source code. What is the fix? I downloaded the tar…
lisprogtor
  • 5,677
  • 11
  • 17
5
votes
3 answers

Reuse parent symbols in child module

I am seeking to re-use the same role/class names in a child module as in its parent. You know, like a specialization. The aim is to be able to re-use the same script code for both the parent and child Series variants by simply changing use Dan to…
librasteve
  • 6,832
  • 8
  • 30
5
votes
1 answer

Null regex not allowed Missing block

Got this simple grammar: grammar H1 { token TOP {

} token h1 { \# } } Results in: Null regex not allowed Missing block Google turns up next to nothing on it.

StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

How to make a class that inherits the same methods as IO::Path?

I want to build a class in Raku. Here's what I have so far: unit class Vimwiki::File; has Str:D $.path is required where *.IO.e; method size { return $.file.IO.s; } I'd like to get rid of the size method by simply making my class inherit the…
StevieD
  • 6,925
  • 2
  • 25
  • 45
5
votes
1 answer

Enforcing single instances from the metamodel

I know that it's way easier to ensure single instances from the class level, and that there's the excellent Staticish module from Jonathan Stowe that does the same by using roles, but I just want to try and understand a bit better how the class…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86