raku

Do we need to modify a script to be able to use the timeline visualization of CommaIDE

不想你离开。 提交于 2020-01-05 05:55:43
问题 I am running a concurrent script from CommaIDE, and it shows only "Waiting for timeline data" while the status line shows "Timeline connection error: Could not get timeline data: java.net.ConnectException: refused connection" Is there any additional configuration I need to do somewhere? Here's the error in the Event Log: 11:05 Timeline connection error: Could not get timeline data: java.net.ConnectException: Conexión rehusada 回答1: Is there any additional configuration I need to do somewhere?

Does .parse anchor or :sigspace first in a Perl 6 rule?

拜拜、爱过 提交于 2020-01-04 09:12:10
问题 I have two questions. Is the behavior I show correct, and if so, is it documented somewhere? I was playing with the grammar TOP method. Declared as a rule , it implies beginning- and end-of-string anchors along with :sigspace : grammar Number { rule TOP { \d+ } } my @strings = '137', '137 ', ' 137 '; for @strings -> $string { my $result = Number.parse( $string ); given $result { when Match { put "<$string> worked!" } when Any { put "<$string> failed!" } } } With no whitespace or trailing

perl6/rakudo: How could I disable autoflush?

对着背影说爱祢 提交于 2020-01-03 17:15:30
问题 I tried this, but it didn't work: $*OUT.autoflush( 0 ); 回答1: $*OUT.autoflush = False should disable it, and it runs without error, but it seems that parrot's IO still flushes automatically. So there currently doesn't seem to be an easy way. 回答2: Rakudo doesn't support autoflush. There's a note in 5to6-perlvar under the $OUTPUT_AUTOFLUSH entry. Some examples from a long time ago mention an autoflush method, but that has disappeared: $*ERR.autoflush = True; $*ERR.say: "1. This is an error"; $

perl6/rakudo: Does perl6 enable “autoflush” by default?

放肆的年华 提交于 2020-01-03 15:59:39
问题 #!perl6 use v6; my $message = "\nHello!\n\nSleep\nTest\n\n"; my @a = $message.split( '' ); for @a { sleep 0.3; .print; } Does perl6 enable "autoflush" by default. With perl5 without enabling "outflush" I don't get this behavior. 回答1: Rakudo enables autoflush by default; the specification is silent about the default. 回答2: Quoting from the docs regarding auto flush: ‘No global alternative available. TTY handles are unbuffered by default, for others, set out-buffer to zero or use :!out-buffer

Difference in capturing and non-capturing regex scope in Perl 6 / Raku

痴心易碎 提交于 2020-01-03 15:20:12
问题 Although the docs state that calling a token/rule/regex as <.foo> instead of <foo> makes them non-capturing, it seems there is a difference in scope, but I'm not sure if it's intended. Here is a simplified test. In a module file: unit module Foo; my token y { y } my token a is export { x <y> } my token b is export { x <.y> } Inside of another script file: grammar A { use Foo; token TOP { <a> } } grammar B { use Foo; token TOP { <b> } } If we calling A.parse("xy") everything runs as expected.

Perl6: How to find all installed modules whose filename matches a pattern?

你说的曾经没有我的故事 提交于 2020-01-03 12:25:34
问题 Is it possible in Perl6 to find all installed modules whose file-name matches a pattern? In Perl5 I would write it like this: use File::Spec::Functions qw( catfile ); my %installed; for my $dir ( @INC ) { my $glob_pattern = catfile $dir, 'App', 'DBBrowser', 'DB', '*.pm'; map { $installed{$_}++ } glob $glob_pattern; } 回答1: There is currently no way to get the original file name of an installed module. However it is possible to get the module names sub list-installed { my @curs = $*REPO.repo

How can I pass arguments to a Perl 6 grammar?

扶醉桌前 提交于 2020-01-03 10:26:39
问题 In Edit distance: Ignore start/end, I offered a Perl 6 solution to a fuzzy fuzzy matching problem. I had a grammar like this (although maybe I've improved it after Edit #3): grammar NString { regex n-chars { [<.ignore>* \w]**4 } regex ignore { \s } } The literal 4 itself was the length of the target string in the example. But the next problem might be some other length. So how can I tell the grammar how long I want that match to be? 回答1: Although the docs don't show an example or using the

How can I send a signal to a process ID in Perl 6?

人盡茶涼 提交于 2020-01-03 09:38:48
问题 Perl 6 has ways to accept signals and to send a signal to a Proc::Async. Although the [p5-p6 perlfunc] docs says that kill works much like is does in Perl 5, it doesn't because you can't send a signal to an arbitrary process ID (doc issue filed). I had a particular program I wanted to write in Perl 6 (for giggles), but was forced to fall back to Perl 5 for lack of a reliable kill. Short of shelling out to kill or tasklist (and taskkill ), is this something we'll just have to do without. There

How do I access the optional parts of a grammar in perl6?

不羁的心 提交于 2020-01-03 09:08:14
问题 As part of my grammar I have: rule EX1 { <EX2> ( '/' <EX2>)* } In my actions class I have written: method EX1($/) { my @ex2s = map *.made, $/.<EX2>; my $ex1 = @ex2s.join('|'); #say "EX1 making $ex1"; $/.make($ex1); } So basically I am just trying to join all the EX2 's together with a '|' between them instead of a '/' . However something is not right with my code, as it only picks up the first EX2 , not the subsequent ones. How do I find out what the optional ones are? 回答1: TL;DR Your action

perl6 “P6opaque, Str” vs simple “Str” types

霸气de小男生 提交于 2020-01-03 08:19:09
问题 I was trying to obtain a list from user input doing my usual codes, but sometimes it fails unpredictably due to this error: This type cannot unbox to a native integer: P6opaque, Str The code line is my @a = prompt("Enter list: ").words || (1,2,3); It failed only if I enter only one number. When is a Str converted to "P6opaque, Str" without user awareness? I cannot use +@a[0] or @a[0].Int to convert this "P6opaque, Str" to an Int. What am I missing here? Thank you very much for your help !!!