raku

Is that one argument or none for a Perl 6 block?

风格不统一 提交于 2020-01-01 09:43:12
问题 What is the Perl 6 way to tell the difference between an argument and no argument in a block with no explicit signature? I don't have any practical use for this, but I'm curious. A block with no explicit signature puts the value into $_ : my &block := { put "The argument was $_" }; The signature is actually ;; $_? is raw . That's one optional argument. The @_ variable isn't defined in the block because there is no explicit signature. There's the no argument, where $_ will be undefined: &block

Does Perl6 support dependent types?

馋奶兔 提交于 2020-01-01 04:18:12
问题 I was recently looking at the wikipedia page for dependent types, and I was wondering; does Perl 6 actually introduce dependent types? I can't seem to find a reliable source claiming that. It might be obvious to some, but it sure as heck ain't obvious to me. 回答1: Against Ven, in the comments following the Perl 6 answer to the SO question "Is there a language with constrainable types?", wrote "perl6 doesn't have dependant types" and later wrote "dependent type, probably not, ... well, if we

I know Perl 5. What are the advantages of learning Perl 6, rather than moving to Python? [closed]

柔情痞子 提交于 2019-12-31 17:58:42
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python? Edit: If you downvoted this because you think

I know Perl 5. What are the advantages of learning Perl 6, rather than moving to Python? [closed]

限于喜欢 提交于 2019-12-31 17:56:32
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python? Edit: If you downvoted this because you think

Using a hash with object keys in Perl 6

坚强是说给别人听的谎言 提交于 2019-12-31 01:44:08
问题 I'm trying to make a Hash with non-string keys, in my case arrays or lists. > my %sum := :{(1, 3, 5) => 9, (2, 4, 6) => 12} {(1 3 5) => 9, (2 4 6) => 12} Now, I don't understand the following. How to retrieve an existing element? > %sum{(1, 3, 5)} ((Any) (Any) (Any)) > %sum{1, 3, 5} ((Any) (Any) (Any)) How to add a new element? > %sum{2, 4} = 6 (6 (Any)) 回答1: Elizabeth's answer is solid, but until that feature is created, I don't see why you can't create a Key class to use as the hash key,

Access POD from another Perl 6 file

余生长醉 提交于 2019-12-30 18:31:40
问题 The Perl 6 POD documentation has a section on accessing the current file's POD document by using $=pod . There is no information on accessing another file's POD document. How can I access another file's POD structure, without altering the current file's $=pod ? 回答1: You can now do that with Pod::Load. From the README in the examples directory perl6 -e 'use Pod::Load; .perl.say for load("pod-load-clean.pod6")' Please note that the Pod6 file has to be "clean", that is, not use any external

Can I change the Perl 6 slang inside a method?

我与影子孤独终老i 提交于 2019-12-30 10:34:14
问题 A Perl 6 Regex is a more specific type of Method, so I had the idea that maybe I could do something black-magicky in a regular method that produces the same thing. I particularly am curious about doing this without changing any grammars. However, looking at Perl6/Grammar.nqp (which I barely understand), that this is really not an inheritance thing. I think, based on my reading, that the Perl 6 grammar switches slangs (sub languages) when it sees one of the regex declarators. That is, a

Why don't all the shell processes in my promises (start blocks) run? (Is this a bug?)

烈酒焚心 提交于 2019-12-30 08:16:30
问题 I want to run multiple shell processes, but when I try to run more than 63, they hang. When I reduce max_threads in the thread pool to n , it hangs after running the n th shell command. As you can see in the code below, the problem is not in start blocks per se, but in start blocks that contain the shell command: #!/bin/env perl6 my $*SCHEDULER = ThreadPoolScheduler.new( max_threads => 2 ); my @processes; # The Promises generated by this loop work as expected when awaited for @*ARGS -> $item

Use of colon in method and function calls in Perl 6

邮差的信 提交于 2019-12-29 07:42:21
问题 I'm wondering what colons have to do with method and function calls in Perl 6. For the record, I am using perl6 version 2015.05-55-gd84bbbc built on MoarVM version 2015.05. I just saw the following in a Perl6 spec test (S32-io) (I added the comment): $fh.print: "0123456789A"; # prints '0123456789A' to the file As far as I can tell, this is equivalent to: $fh.print("0123456789A"); # prints '0123456789A' to the file Both of these seem to take multiple arguments and to flatten lists fine: $fh

Perl 6: trans(%h) vs trans(%h.keys => %h.values)

一世执手 提交于 2019-12-23 19:39:44
问题 Yet another question about hash as argument for trans . In the following code taking simply hash gives an incorrect result, but replacing it with keys and values makes it correct. What is wrong? my @alph1 = <a+ b+ c+ d+ e+ f+>; my @alph2 = <A_ B_ C_ D_ E_ F_>; my %h; %h{ @alph1 } = @alph2; my $str = 'a+bc de+f'; my $text = $str.trans(%h); say $text; # A_BC DE_F (incorrect) $text = $str.trans(%h.keys => %h.values); say $text; # A_bc dE_f (correct) 回答1: I think you misunderstand what .trans