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

Raku: how to sort `dir` results by directory age?

I am trying to get a list of directories by age in Raku, which is equivalent to Bash ls -tl | grep ^dr but I am unsure how to sort the results by age, if this is even possible for dir (test => {$_.IO.d}) -> $dir {...} how can I sort these results by…
con
  • 5,767
  • 8
  • 33
  • 62
5
votes
4 answers

Implementing iterable classes with the Iterable and Iterator roles

Suppose we have the following class composing the role Iterable: class Word-Char does Iterable { has @.words; method !pairize($item) { return $item => $item.chars; } method iterator( Word-Char:D: ) { …
uzluisf
  • 2,586
  • 1
  • 9
  • 27
5
votes
3 answers

Can * be used in sym tokens for more than one character?

The example for sym shows * (WhateverCode) standing in for a single symbol grammar Foo { token TOP { + } proto token letter {*} token letter:sym

{ } token letter:sym { } token letter:sym { } …

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
2 answers

Dangling topic (or any other) variable does not fail

This works: $_ = say "hi"; That is, you can put any amount of whitespace between an assignment and stuff that's behind, it will simply ignore it. You can use any variable (with my) too. Effectively, $_ will be assigned the result of the say, which…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

Calling Bool on a Regex does not work as documented

According to the documentation, Bool method of Regex class... Matches against the caller's $_ variable, and returns True for a match or False for no match. However, in this example $_ = "3"; my regex decimal { \d }; say &decimal.Bool; returns…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
3 answers

CONTROL or once messes with last?

This loop never stops: class CX::Vaya does X::Control { has $.message } loop { once { CX::Vaya.new( message => "I messed up!" ).throw; } last; CONTROL { default { say "Controlled { .^name }: {…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
2 answers

Mixing-in roles in traits apparently not working

This example is taken from roast, although it's been there for 8 years: role doc { has $.doc is rw } multi trait_mod:(Variable $a, :$docced!) { $a does doc.new(doc => $docced); } my $dog is docced('barks'); say $dog.VAR; This returns Any,…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

Problems using POSITIONS and Code objects

I am trying to create an object that implements POSTIONS for slicing class Foo is Code { multi method POSITIONS( Foo:D $foo: \pos) { 1,2 } }; say [Foo.new] This errors with "Cannot make a Foo object using .new". Making it a standalone…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

"Can't open perl script "t/spec/fudgeall": File or directory not found"

I am trying to run some tests for Rakudo following instructions in the README.md, that is, with perl Configure.pl and make. However, when I run make t/02-rakudo/09-thread-id-after-await.t after that, it…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
2 answers

Print embedded Pod as formatted text with termcap escapes

I am trying to output embedded Pod as ANSI text to the terminal. In Perl 5 I can use Pod::Text::Termcap: use strict; use warnings; use Pod::Text::Termcap; my $str = do {local $/; }; my $parser =…
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
5
votes
1 answer

How to determine the absolute path name of the compilation unit of the caller?

According to p6doc 5to6-perlfunc: FILE Replaced by $?FILE which is slightly different from __FILE__ in that it is always an absolute path, rather than a relative one in the Perl 5 case. and according to p6doc CallFrame: With no arguments the…
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
5
votes
0 answers

Errors using Metamodel::ConcreteRoleHOW.new_type

There does not seem to be a way to use new_type in MetamodelConcreteRoleHOW, which as its name implies should be used to create new instances of a Role. The main problem is when you try to mix-in new roles, as implied by the signature ( method…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5
votes
1 answer

How do I decompress a Git object properly in Raku Perl 6?

I have the following Python code snippet: import zlib def object_read(repo, sha): path = repo + "/objects/" + sha[0:2] + "/" + sha[2:] with open (path, "rb") as f: raw = zlib.decompress(f.read()) return…
uzluisf
  • 2,586
  • 1
  • 9
  • 27
5
votes
2 answers

When I run a perl raku command line program a lib directory appears in the current working directory - how do I prevent this?

When I run a perl raku command-line program a lib directory (and precomp files) appear in the current working directory - how can I prevent/avoid this?
user2145475
  • 657
  • 3
  • 11
5
votes
1 answer

Useless use of hash composer, or cannot modify an immutable hash?

This code: constant %what = { doesn't => 'change' }; %what = { will => "change" } Should say something along the lines of "Cannot modify an immutable hash". However, it says: Potential difficulties: Useless use of hash composer on right side of…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
1 2 3
99
100