perl.perl6.users http://www.nntp.perl.org/group/perl.perl6.users/ ... Copyright 1998-2014 perl.org Tue, 02 Sep 2014 00:33:57 +0000 ask@perl.org # Announce: Rakudo Star Release 2014.08 by Tobias Leich # Announce: Rakudo Star Release 2014.08<br/><br/>## A useful, usable, &quot;early adopter&quot; distribution of Perl 6<br/><br/>On behalf of the Rakudo and Perl 6 development teams, I&#39;m happy to<br/>announce the August 2014 release of &quot;Rakudo Star&quot;, a useful and usable<br/>distribution of Perl 6. The tarball for the August 2014 release is<br/>available from &lt;http://rakudo.org/downloads/star/&gt;. A Windows .MSI<br/>version of Rakudo star will usually appear in the downloads area<br/>shortly after the tarball release.<br/><br/>This Rakudo Star release comes with support for the MoarVM<br/>backend (all module tests pass on supported platforms) along with<br/>experimental support for the JVM backend (some module tests fail).<br/>One shipped module is known to fail on Parrot (JSON::RPC).<br/><br/>In the Perl 6 world, we make a distinction between the language<br/>(&quot;Perl 6&quot;) and specific implementations of the language such as<br/>&quot;Rakudo Perl&quot;. This Star release includes [release 2014.08] of the<br/>[Rakudo Perl 6 compiler], version 6.7.0 of the [Parrot Virtual<br/>Machine], version 2014.08 of [MoarVM], plus various modules,<br/>documentation, and other resources collected from the Perl 6<br/>community.<br/><br/>[release 2014.08]:<br/> https://github.com/rakudo/rakudo/blob/nom/docs/announce/2014.05.md<br/> https://github.com/rakudo/rakudo/blob/nom/docs/announce/2014.06.md<br/> https://github.com/rakudo/rakudo/blob/nom/docs/announce/2014.07.md<br/> https://github.com/rakudo/rakudo/blob/nom/docs/announce/2014.08.md<br/>[Rakudo Perl 6 compiler]: http://github.com/rakudo/rakudo<br/>[Parrot Virtual Machine]: http://parrot.org<br/>[MoarVM]: http://moarvm.org/<br/><br/>Some of the new features added to this release include:<br/><br/>* Many optimizations in both rakudo and the underlying VMs.<br/>* If the LOLLY envar is set, have (;;), [;;], etc., turn into LoLs.<br/>Otherwise, parsefail<br/>* Add SEQ(a; b) to emulate the old behavior of (a; b)<br/>* Make &amp;infix:&lt;xx&gt; many times faster<br/>* fix multi-dimensional slice assignment<br/>* assigning a single itemized hash to a hash is now DEPRECATED (my %h =<br/>{...})<br/>* subbuf-rw specced and implemented<br/>* the tr/// operator is implemented and has the proper return value<br/>* improved string handling for MoarVM backend<br/>* all backends now allow C pointer arithmetic and casting of pointers to<br/>Perl 6 types (this functionality is exposed by NativeCall)<br/>* fixed &#39;fail&#39; so it also prints a backtrace<br/>* IO::Socket::Async now also works on JVM<br/>* added or updated many Supply methods: act, batch, categorize, Channel,<br/>classify, delay, elems, flat, grab, last, live, max, min, minmax, merge,<br/>migrate, Promise, reduce, reverse, rotor, sort, squish, stable, start,<br/>uniq, wait, zip<br/>* added IO::Notification.watch_path / IO::Path::watch which return a<br/>Supply of file system changes<br/>* added first-index, last-index, grep-index subs/methods<br/>* deprecate $*OS, $*OSVER, $*VM, $*PERL...<br/>* added $*KERNEL, $*DISTRO, $*VM, $*PERL as full blown objects<br/>* &quot;use v5&quot; is no longer a noop, but actually tries to load the &quot;v5&quot;<br/>module (soon available as part of Rakudo*)<br/>* implemented labeled loops and throwing of labels as payload<br/><br/>There are some key features of Perl 6 that Rakudo Star does not yet<br/>handle appropriately, although they will appear in upcoming releases.<br/>Some of the not-quite-there features include:<br/><br/> * advanced macros<br/> * threads and concurrency (in progress for the JVM and MoarVM backend)<br/> * Unicode strings at levels other than codepoints<br/> * interactive readline that understands Unicode<br/> * non-blocking I/O<br/> * much of Synopsis 9 and 11<br/><br/>There is an online resource at &lt;http://perl6.org/compilers/features&gt;<br/>that lists the known implemented and missing features of Rakudo and<br/>other Perl 6 implementations.<br/><br/>In many places we&#39;ve tried to make Rakudo smart enough to inform the<br/>programmer that a given feature isn&#39;t implemented, but there are many<br/>that we&#39;ve missed. Bug reports about missing and broken features are<br/>welcomed at &lt;rakudobug@perl.org&gt;.<br/><br/>See &lt;http://perl6.org/&gt; for links to much more information about<br/>Perl 6, including documentation, example code, tutorials, reference<br/>materials, specification documents, and other supporting resources. A<br/>draft of a Perl 6 book is available as docs/UsingPerl6-draft.pdf in<br/>the release tarball.<br/><br/>The development team thanks all of the contributors and sponsors for<br/>making Rakudo Star possible. If you would like to contribute, see<br/>&lt;http://rakudo.org/how-to-help&gt;, ask on the &lt;perl6-compiler@perl.org&gt;<br/>mailing list, or join us on IRC \#perl6 on freenode.<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/08/msg1814.html Sat, 30 Aug 2014 22:08:48 +0000 Re: Grammars and biological data formats by Fields, Christopher J On Aug 9, 2014, at 8:51 PM, &quot;Fields, Christopher J&quot; &lt;cjfields@illinois.edu&gt; wrote:<br/>&gt; <br/>&gt; <br/>&gt;&gt; On Aug 9, 2014, at 5:25 PM, &quot;timo@wakelift.de&quot; &lt;timo@wakelift.de&gt; wrote:<br/>&gt;&gt; <br/>&gt;&gt; <br/>&gt;&gt;&gt; On 08/10/2014 12:21 AM, timo@wakelift.de wrote:<br/>&gt;&gt;&gt; Something that does surprise me is that your tests seem to imply that :p<br/>&gt;&gt;&gt; for subparse doesn&#39;t work. I&#39;ll look into that, because I believe it<br/>&gt;&gt;&gt; ought to be implemented already. Perhaps not properly hooked up, though.<br/>&gt;&gt; <br/>&gt;&gt; On #perl6 I got corrected quite quickly: subparse is anchored to the<br/>&gt;&gt; start and end of the target string, so :pos doesn&#39;t make sense. In this<br/>&gt;&gt; case, you want just .parse<br/>&gt; <br/>&gt; I mainly tested subparse() to see if it would find the second FASTA record (which works if using :p and not :pos).<br/>&gt; <br/>&gt; Sorry, I should have updated that, but subparse() with :p works fine; the spec mentions :pos though (I plan on submitting a pull request on that).<br/>&gt; <br/>&gt;&gt; Another thing is that if lines() does keep all data around, it should be<br/>&gt;&gt; considered a bug, as we should be able to infer that we don&#39;t keep the<br/>&gt;&gt; list itself around and thus won&#39;t be able to refer to its previous<br/>&gt;&gt; values later on. Thus, we should free the memory for the earlier lines<br/>&gt;&gt; in the target string after the loop is done with them.<br/>&gt;&gt; <br/>&gt;&gt; I have not yet tested, if this is the case, though.<br/>&gt;&gt; <br/>&gt;&gt; Hope that clears up a bit of potential confusion before it can arise<br/>&gt;&gt; - Timo<br/>&gt; <br/>&gt; I can try that out.<br/>&gt; <br/>&gt; Chris<br/><br/>Oh, and thanks everyone for the quick replies!<br/><br/>Chris http://www.nntp.perl.org/group/perl.perl6.users/2014/08/msg1813.html Sun, 10 Aug 2014 01:53:07 +0000 Re: Grammars and biological data formats by Fields, Christopher J <br/>&gt; On Aug 9, 2014, at 5:25 PM, &quot;timo@wakelift.de&quot; &lt;timo@wakelift.de&gt; wrote:<br/>&gt; <br/>&gt; <br/>&gt;&gt; On 08/10/2014 12:21 AM, timo@wakelift.de wrote:<br/>&gt;&gt; Something that does surprise me is that your tests seem to imply that :p<br/>&gt;&gt; for subparse doesn&#39;t work. I&#39;ll look into that, because I believe it<br/>&gt;&gt; ought to be implemented already. Perhaps not properly hooked up, though.<br/>&gt; <br/>&gt; On #perl6 I got corrected quite quickly: subparse is anchored to the<br/>&gt; start and end of the target string, so :pos doesn&#39;t make sense. In this<br/>&gt; case, you want just .parse<br/><br/>I mainly tested subparse() to see if it would find the second FASTA record (which works if using :p and not :pos).<br/><br/>Sorry, I should have updated that, but subparse() with :p works fine; the spec mentions :pos though (I plan on submitting a pull request on that).<br/><br/>&gt; Another thing is that if lines() does keep all data around, it should be<br/>&gt; considered a bug, as we should be able to infer that we don&#39;t keep the<br/>&gt; list itself around and thus won&#39;t be able to refer to its previous<br/>&gt; values later on. Thus, we should free the memory for the earlier lines<br/>&gt; in the target string after the loop is done with them.<br/>&gt; <br/>&gt; I have not yet tested, if this is the case, though.<br/>&gt; <br/>&gt; Hope that clears up a bit of potential confusion before it can arise<br/>&gt; - Timo<br/><br/>I can try that out.<br/><br/>Chris<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/08/msg1812.html Sun, 10 Aug 2014 01:51:22 +0000 Re: Grammars and biological data formats by Darren Duncan I&#39;ve already been thinking for awhile now that parsers need to be able to <br/>operate in a streaming fashion (when the grammars lend themselves to it, by not <br/>needing to lookahead, much if at all, to understand what they&#39;ve already seen) <br/>so that strings that don&#39;t fit in memory all at once can be parsed.<br/><br/>Any parser that returns results piecewise to the caller rather than all at once, <br/>such as by supporting callbacks, already makes for a streaming interface on that <br/>end, so it just needs to be lazy on the input end as well, and then one can <br/>parse arbitrary sized inputs while using little memory.<br/><br/>Christopher&#39;s example is a good one.<br/><br/>Another example that I would deal with is database dumps; the parsers in psql or <br/>mysql or others can obviously handle SQL dump files that are many gigabytes and <br/>are obviously parsing them in a streaming manner, but SQL files are really just <br/>program source code files.<br/><br/>-- Darren Duncan<br/><br/>On 2014-08-09, 3:09 PM, Fields, Christopher J wrote:<br/>&gt; (accidentally sent to perl6-lang, apologies for cross-posting but this seems more appropriate)<br/>&gt;<br/>&gt; I have a fairly simple question regarding the feasibility of using grammars with commonly used biological data formats.<br/>&gt;<br/>&gt; My main question: if I wanted to parse() or subparse() vary large files (not unheard of to have FASTA/FASTQ or other similar data files exceed 100&rsquo;s of GB) would a grammar be the best solution? For instance, based on what I am reading the semantics appear to be greedy; for instance:<br/>&gt;<br/>&gt; Grammar.parsefile($file)<br/>&gt;<br/>&gt; appears to be a convenient shorthand for:<br/>&gt;<br/>&gt; Grammar.parse($file.slurp)<br/>&gt;<br/>&gt; since Grammar.parse() works on a Str, not a IO::Handle or Buf. Or am I misunderstanding how this could be accomplished?<br/>&gt;<br/>&gt; (just to point out, I know I can subparse() as well but that also appears to act on a string&hellip;)<br/>&gt;<br/>&gt; As an example, I have a simple grammar for parsing FASTA, which a (deceptively) simple format for storing sequence data:<br/>&gt;<br/>&gt; http://en.wikipedia.org/wiki/FASTA_format<br/>&gt;<br/>&gt; I have a simple grammar here:<br/>&gt;<br/>&gt; https://github.com/cjfields/bioperl6/blob/master/lib/Bio/Grammar/Fasta.pm6<br/>&gt;<br/>&gt; and tests here:<br/>&gt;<br/>&gt; https://github.com/cjfields/bioperl6/blob/master/t/Grammar/fasta.t<br/>&gt;<br/>&gt; Tests pass with the latest Rakudo just fine.<br/>&gt;<br/>&gt; chris<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/08/msg1811.html Sat, 09 Aug 2014 22:33:51 +0000 Re: Grammars and biological data formats by timo <br/>On 08/10/2014 12:21 AM, timo@wakelift.de wrote:<br/>&gt; Something that does surprise me is that your tests seem to imply that :p<br/>&gt; for subparse doesn&#39;t work. I&#39;ll look into that, because I believe it<br/>&gt; ought to be implemented already. Perhaps not properly hooked up, though.<br/><br/>On #perl6 I got corrected quite quickly: subparse is anchored to the<br/>start and end of the target string, so :pos doesn&#39;t make sense. In this<br/>case, you want just .parse<br/><br/>Another thing is that if lines() does keep all data around, it should be<br/>considered a bug, as we should be able to infer that we don&#39;t keep the<br/>list itself around and thus won&#39;t be able to refer to its previous<br/>values later on. Thus, we should free the memory for the earlier lines<br/>in the target string after the loop is done with them.<br/><br/>I have not yet tested, if this is the case, though.<br/><br/>Hope that clears up a bit of potential confusion before it can arise<br/> - Timo<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/08/msg1810.html Sat, 09 Aug 2014 22:25:21 +0000 Re: Grammars and biological data formats by timo (accidentally sent this privately only, now re-sending to the list)<br/><br/>Hello Christopher,<br/><br/>In the Perl&#x202F;6 specification, there are plans for lazy and<br/>memory-releasing ways to parse strings that are either too large to fit<br/>into memory at once or that are generated lazily (like being streamed in<br/>through the network or using &quot;live&quot; data sources). Sadly, none of those<br/>features are implemented in either of our backends.<br/><br/>The simplest thing we have is the &lt;cut&gt; rule, which should instruct the<br/>grammar engine to deallocate the parts of the input data that are before<br/>the current cursor. Sadly, this is not going to help you much at this stage.<br/><br/>Another thing that will be unhelpful is that our lazy lists (such as the<br/>ones you can generate with gather/take or what lines() will give you)<br/>will keep all items from the very first to the last you&#39;ve requested<br/>around until the whole list becomes garbage and gets collected.<br/><br/>It would seem like you&#39;ll want to do a line-by-line iteration through<br/>the data using not lines() but get() and manually parse the individual<br/>lines; the grammar seems sufficiently simple for that to work.<br/><br/>Something that does surprise me is that your tests seem to imply that :p<br/>for subparse doesn&#39;t work. I&#39;ll look into that, because I believe it<br/>ought to be implemented already. Perhaps not properly hooked up, though.<br/><br/>Hope to help!<br/>- Timo<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/08/msg1809.html Sat, 09 Aug 2014 22:21:57 +0000 Grammars and biological data formats by Fields, Christopher J (accidentally sent to perl6-lang, apologies for cross-posting but this seems more appropriate)<br/><br/>I have a fairly simple question regarding the feasibility of using grammars with commonly used biological data formats. <br/><br/>My main question: if I wanted to parse() or subparse() vary large files (not unheard of to have FASTA/FASTQ or other similar data files exceed 100&#146;s of GB) would a grammar be the best solution? For instance, based on what I am reading the semantics appear to be greedy; for instance:<br/><br/> Grammar.parsefile($file)<br/><br/>appears to be a convenient shorthand for:<br/><br/> Grammar.parse($file.slurp)<br/><br/>since Grammar.parse() works on a Str, not a IO::Handle or Buf. Or am I misunderstanding how this could be accomplished?<br/><br/>(just to point out, I know I can subparse() as well but that also appears to act on a string&#133;)<br/><br/>As an example, I have a simple grammar for parsing FASTA, which a (deceptively) simple format for storing sequence data:<br/><br/> http://en.wikipedia.org/wiki/FASTA_format<br/><br/>I have a simple grammar here:<br/><br/> https://github.com/cjfields/bioperl6/blob/master/lib/Bio/Grammar/Fasta.pm6<br/><br/>and tests here:<br/><br/> https://github.com/cjfields/bioperl6/blob/master/t/Grammar/fasta.t<br/><br/>Tests pass with the latest Rakudo just fine.<br/><br/>chris<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/08/msg1808.html Sat, 09 Aug 2014 22:10:12 +0000 Re: perl6 hackathon at fpw'14? by Marc Chantreux hello sixers, <br/><br/>&gt; &gt;* s-exml (which is about writting a grammar in perl6 or NQP),<br/>&gt; &gt; a s-expression based dialect to generate xml:<br/>&gt; <br/>&gt; This looks like fun to me :) <br/><br/>thanks! i just put a first version on my github <br/><br/>https://github.com/eiro/p6-lab/blob/master/sexml.p6<br/><br/>next moves would be:<br/><br/>* write more perl6ish code<br/>* add some templating features as tags to have things like<br/><br/> {? users<br/> {ul {@ users u {li {$u.firstname} {$u.lastname} } }}<br/> }<br/><br/>YA way to learn some perl6 code.<br/><br/>regards<br/><br/>-- <br/>Marc Chantreux (eiro on github and freenode)<br/>http://eiro.github.com/<br/>http://eiro.github.com/atom.xml<br/>&quot;Don&#39;t believe everything you read on the Internet&quot;<br/> -- Abraham Lincoln<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1807.html Wed, 30 Jul 2014 13:28:33 +0000 Re: Could you give me some explanatio​ns about regex? by Brandon Allbery On Tue, Jul 15, 2014 at 11:16 AM, MAX PUX &lt;isleofmax@gmail.com&gt; wrote:<br/><br/>&gt; I expected this output:<br/>&gt; website<br/>&gt; ForeignAssistance<br/>&gt; ForeignAssistanceRow<br/>&gt; AssistanceType<br/>&gt; RecipientCountry<br/>&gt; ProgramName<br/>&gt;<br/>&gt; but the output was:<br/>&gt;<br/>&gt; &#x2514;website&#x2510;<br/>&gt;<br/>&gt; &#x2514;ForeignAssistance&#x2510;<br/>&gt;<br/>&gt; &#x2514;ForeignAssistanceRow&#x2510;<br/>&gt;<br/><br/>$/[0] is a Match object, which is being &quot;visualized&quot; by `say` instead of<br/>simple stringification, as it can have submatches, has interpretations as<br/>boolean and number, etc. You can force conversion to a string with `.Str`<br/>suffix or prefix `~`, or by using it as a string (e.g. concatenation with<br/>another string).<br/><br/>-- <br/>brandon s allbery kf8nh sine nomine associates<br/>allbery.b@gmail.com ballbery@sinenomine.net<br/>unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1806.html Tue, 15 Jul 2014 15:42:20 +0000 Re: Could you give me some explanatio​ns about regex? by Pawel Pabian Hi<br/><br/>You can force correct stringification method by explicit convaersion<br/><br/>say $/[0].Str<br/><br/>or using print which uses it implicitly<br/><br/>print $/[0] ~ &quot;\n&quot;<br/><br/><br/>bbkr<br/><br/><br/>On 15 Jul 2014, at 17:16, MAX PUX &lt;isleofmax@gmail.com&gt; wrote:<br/><br/>&gt; I&#39;ve written this code:<br/>&gt; use v6;<br/>&gt; <br/>&gt; my $file =3D open &quot;us_foreign_assistance.xml&quot;;<br/>&gt; <br/>&gt; for $file.lines -&gt; $line {<br/>&gt; extract($line);<br/>&gt; }<br/>&gt; <br/>&gt; sub extract($line) {<br/>&gt; if $line ~~ m/ \&lt; (\w+) \&gt; / {<br/>&gt; say $/[0];<br/>&gt; }<br/>&gt; }<br/>&gt; <br/>&gt; The xml file contains:<br/>&gt; &lt; ?xml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot; standalone=3D&quot;yes&quot;?&gt;<br/>&gt; &lt; website&gt;http://gbk.eads.usaidallnet.gov/data/detailed.html&lt;/website&gt;<br/>&gt; &lt; ForeignAssistance&gt;<br/>&gt; &lt;ForeignAssistanceRow&gt;<br/>&gt; &lt;AssistanceType&gt;Economic&lt;/AssistanceType&gt;<br/>&gt; &lt;RecipientCountry&gt;Afghanistan&lt;/RecipientCountry&gt;<br/>&gt; &lt;ProgramName&gt;Child Survival and Health&lt;/ProgramName&gt;<br/>&gt; ecc. ecc.<br/>&gt; <br/>&gt; I expected this output:<br/>&gt; website<br/>&gt; ForeignAssistance<br/>&gt; ForeignAssistanceRow<br/>&gt; AssistanceType<br/>&gt; RecipientCountry<br/>&gt; ProgramName<br/>&gt; <br/>&gt; but the output was:<br/>&gt; <br/>&gt; &#x2514;website&#x2510;<br/>&gt; <br/>&gt; &#x2514;ForeignAssistance&#x2510;<br/>&gt; <br/>&gt; &#x2514;ForeignAssistanceRow&#x2510;<br/>&gt; <br/>&gt; &#x2514;AssistanceType&#x2510;<br/>&gt; <br/>&gt; &#x2514;RecipientCountry&#x2510;<br/>&gt; <br/>&gt; &#x2514;ProgramName&#x2510;<br/>&gt; <br/>&gt; Could someone explain me where I go wrong?<br/>&gt; <br/>&gt; Thanks and sorry for my bad english,<br/>&gt; Massimo<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1805.html Tue, 15 Jul 2014 15:28:38 +0000 Could you give me some explanatio​ns about regex? by MAX PUX I&#39;ve written this code:<br/>use v6;<br/><br/>my $file =3D open &quot;us_foreign_assistance.xml&quot;;<br/><br/>for $file.lines -&gt; $line {<br/> extract($line);<br/>}<br/><br/>sub extract($line) {<br/> if $line ~~ m/ \&lt; (\w+) \&gt; / {<br/> say $/[0];<br/> }<br/>}<br/><br/>The xml file contains:<br/>&lt; ?xml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot; standalone=3D&quot;yes&quot;?&gt;<br/>&lt; website&gt;http://gbk.eads.usaidallnet.gov/data/detailed.html&lt;/website&gt;<br/>&lt; ForeignAssistance&gt;<br/> &lt;ForeignAssistanceRow&gt;<br/> &lt;AssistanceType&gt;Economic&lt;/AssistanceType&gt;<br/> &lt;RecipientCountry&gt;Afghanistan&lt;/RecipientCountry&gt;<br/> &lt;ProgramName&gt;Child Survival and Health&lt;/ProgramName&gt;<br/>ecc. ecc.<br/><br/>I expected this output:<br/>website<br/>ForeignAssistance<br/>ForeignAssistanceRow<br/>AssistanceType<br/>RecipientCountry<br/>ProgramName<br/><br/>but the output was:<br/><br/>&#x2514;website&#x2510;<br/><br/>&#x2514;ForeignAssistance&#x2510;<br/><br/>&#x2514;ForeignAssistanceRow&#x2510;<br/><br/>&#x2514;AssistanceType&#x2510;<br/><br/>&#x2514;RecipientCountry&#x2510;<br/><br/>&#x2514;ProgramName&#x2510;<br/><br/>Could someone explain me where I go wrong?<br/><br/>Thanks and sorry for my bad english,<br/> Massimo<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1804.html Tue, 15 Jul 2014 15:16:24 +0000 Re: match an empty string? by Moritz Lenz Hi all,<br/><br/>On 13.07.2014 00:15, David Warring wrote:<br/>&gt; Hi Marc,<br/>&gt; This looks like a Perl 5 complementary character match: [^:]*<br/>&gt; <br/>&gt; But it means something quite different in Perl6. From S05<br/>&gt; &lt;http://perlcabal.org/syn/S05.html&gt;<br/>&gt; <br/>&gt; Bracket rationalization<br/>&gt; &lt;http://perlcabal.org/syn/S05.html#Bracket_rationalization&gt; [ ... ] is<br/>&gt; no longer a character class. It now delimits a non-capturing group.<br/>&gt; <br/>&gt; |Changed metacharacters<br/>&gt; &lt;http://perlcabal.org/syn/S05.html#Changed_metacharacters&gt;^| and |$| now<br/>&gt; always match the start/end of a string<br/>&gt; <br/>&gt; Backtracking control<br/>&gt; &lt;http://perlcabal.org/syn/S05.html#Backtracking_control&gt;To force the<br/>&gt; preceding atom to do no backtracking, use a single |:|<br/>&gt; <br/>&gt; In summary, this pattern is repeatably matching an empty start-of-string.<br/>&gt; <br/>&gt; A Perl 6 equivalent is:<br/>&gt; <br/>&gt; token gecos { &lt;- [&#39;:&#39;]&gt;* }<br/><br/>... but without the quotes. In character classes, quotes have no special<br/>meaning, so &lt;-[&#39;:&#39;]&gt; is the same as &lt;-[:&#39;]&gt;, so it excludes the quote<br/>character.<br/><br/>To just exclude the colon, simply say &lt;-[:]&gt;<br/><br/>(Note that the rules of<br/>http://perlcabal.org/syn/S05.html#Simplified_lexical_parsing_of_patterns<br/>about what is and what isn&#39;t metacharacter don&#39;t apply inside character<br/>classes).<br/><br/>Cheers,<br/>Moritz<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1803.html Sun, 13 Jul 2014 12:18:43 +0000 Re: match an empty string? by Marc Chantreux hello David, <br/><br/>&gt; A Perl 6 equivalent is:<br/>&gt; &nbsp; &nbsp; token gecos { &lt;- [&#39;:&#39;]&gt;* }<br/><br/>thanks for those explainations. jnthn gave those yesterday on the <br/>friendly #perl6 freenode channel and i have to admit i&#39;m not confortable<br/>with the backtracking part.<br/><br/>Anyway: i got the syntax thing and finished the program. thanks<br/>everyone.<br/><br/>-- <br/>Marc Chantreux (eiro on github and freenode)<br/>http://eiro.github.com/<br/>http://eiro.github.com/atom.xml<br/>&quot;Don&#39;t believe everything you read on the Internet&quot;<br/> -- Abraham Lincoln<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1802.html Sun, 13 Jul 2014 11:06:16 +0000 Re: match an empty string? by David Warring Hi Marc,<br/>This looks like a Perl 5 complementary character match: [^:]*<br/><br/>But it means something quite different in Perl6. From S05<br/>&lt;http://perlcabal.org/syn/S05.html&gt;<br/><br/>Bracket rationalization<br/>&lt;http://perlcabal.org/syn/S05.html#Bracket_rationalization&gt; [ ... ] is no<br/>longer a character class. It now delimits a non-capturing group.<br/><br/>Changed metacharacters<br/>&lt;http://perlcabal.org/syn/S05.html#Changed_metacharacters&gt;^ and $ now<br/>always match the start/end of a string<br/><br/>Backtracking control<br/>&lt;http://perlcabal.org/syn/S05.html#Backtracking_control&gt;To force the<br/>preceding atom to do no backtracking, use a single :<br/><br/>In summary, this pattern is repeatably matching an empty start-of-string.<br/><br/>A Perl 6 equivalent is:<br/><br/> token gecos { &lt;- [&#39;:&#39;]&gt;* }<br/><br/>This matches a complementary character class; all but &#39;:&#39;.<br/><br/>Also, the &lt;home&gt; and &lt;shell&gt; rules aren&#39;t fully matching their test input<br/>at the moment.<br/><br/>Cheers,<br/>- David<br/><br/><br/>On Sat, Jul 12, 2014 at 10:07 AM, Marc Chantreux &lt;mc@unistra.fr&gt; wrote:<br/><br/>&gt; hello,<br/>&gt;<br/>&gt; using perl6 version 2014.04 built on MoarVM version 2014.04<br/>&gt;<br/>&gt; i&#39;m trying to write a grammar to parse the result of a `getent passwd`<br/>&gt; but when i test the gecos (which could be empty), i fall into a loop.<br/>&gt;<br/>&gt; the pb appears whenever i try to match something that can be empty using<br/>&gt; the * quantifier.<br/>&gt;<br/>&gt; I guess i miss a simple point there but i can&#39;t figure out what. Any<br/>&gt; help (or feedback on any other part of the code) would be appreciated.<br/>&gt;<br/>&gt; regards<br/>&gt;<br/>&gt; use v6;<br/>&gt; use Test;<br/>&gt;<br/>&gt; grammar PAccountDB {<br/>&gt; token TOP { ^ &lt;account&gt;* $ }<br/>&gt; token account {<br/>&gt; &lt;login&gt;<br/>&gt; &#39;:&#39; &lt;passwd&gt;<br/>&gt; &#39;:&#39; &lt;uid&gt;<br/>&gt; &#39;:&#39; &lt;gid&gt;<br/>&gt; &#39;:&#39; &lt;gecos&gt;<br/>&gt; &#39;:&#39; &lt;home&gt;<br/>&gt; &#39;:&#39; &lt;shell&gt;<br/>&gt; \n<br/>&gt; }<br/>&gt; token login { &lt;[a..z]&gt;+ }<br/>&gt; token passwd { &#39;x&#39; }<br/>&gt; token numid { \d+ }<br/>&gt; token uid { &lt;.numid&gt; }<br/>&gt; token gid { &lt;.numid&gt; }<br/>&gt; token gecos { [^:]* }<br/>&gt; token path { &#39;/&#39; &lt;-[\x00&#39;/&#39;]&gt;+ }<br/>&gt; token home { &lt;.path&gt; }<br/>&gt; token shell { &lt;.path&gt; }<br/>&gt; }<br/>&gt;<br/>&gt; for<br/>&gt; ( uid =&gt; &#39;445&#39;<br/>&gt; , gid =&gt; &#39;445&#39;<br/>&gt; , shell =&gt; &#39;/bin/false&#39;<br/>&gt; , home =&gt; &#39;/home/mc&#39;<br/>&gt; # , gecos =&gt; &#39;server account,,,&#39;<br/>&gt; , login =&gt; &#39;root&#39; ) {<br/>&gt; my ( $rule, $candidate ) = .kv;<br/>&gt; ok ?PAccountDB.subparse( $candidate, :rule($rule) )<br/>&gt; , &quot;subrule $rule matches $candidate&quot;;<br/>&gt; }<br/>&gt;<br/>&gt;<br/>&gt; --<br/>&gt; Marc Chantreux<br/>&gt; Universit&eacute; de Strasbourg, Direction Informatique<br/>&gt; 14 Rue Ren&eacute; Descartes,<br/>&gt; 67084 STRASBOURG CEDEX<br/>&gt; &#x260E;: 03.68.85.57.40<br/>&gt; http://unistra.fr<br/>&gt; &quot;Don&#39;t believe everything you read on the Internet&quot;<br/>&gt; -- Abraham Lincoln<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1801.html Sat, 12 Jul 2014 22:15:40 +0000 match an empty string? by Marc Chantreux hello, <br/><br/>using perl6 version 2014.04 built on MoarVM version 2014.04<br/><br/>i&#39;m trying to write a grammar to parse the result of a `getent passwd`<br/>but when i test the gecos (which could be empty), i fall into a loop.<br/><br/>the pb appears whenever i try to match something that can be empty using <br/>the * quantifier.<br/><br/>I guess i miss a simple point there but i can&#39;t figure out what. Any<br/>help (or feedback on any other part of the code) would be appreciated. <br/><br/>regards<br/><br/>use v6;<br/>use Test;<br/><br/>grammar PAccountDB {<br/> token TOP { ^ &lt;account&gt;* $ }<br/> token account {<br/> &lt;login&gt;<br/> &#39;:&#39; &lt;passwd&gt;<br/> &#39;:&#39; &lt;uid&gt;<br/> &#39;:&#39; &lt;gid&gt;<br/> &#39;:&#39; &lt;gecos&gt;<br/> &#39;:&#39; &lt;home&gt;<br/> &#39;:&#39; &lt;shell&gt;<br/> \n<br/> } <br/> token login { &lt;[a..z]&gt;+ }<br/> token passwd { &#39;x&#39; }<br/> token numid { \d+ }<br/> token uid { &lt;.numid&gt; }<br/> token gid { &lt;.numid&gt; }<br/> token gecos { [^:]* }<br/> token path { &#39;/&#39; &lt;-[\x00&#39;/&#39;]&gt;+ }<br/> token home { &lt;.path&gt; }<br/> token shell { &lt;.path&gt; }<br/>}<br/><br/>for<br/>( uid =&gt; &#39;445&#39;<br/>, gid =&gt; &#39;445&#39;<br/>, shell =&gt; &#39;/bin/false&#39;<br/>, home =&gt; &#39;/home/mc&#39;<br/># , gecos =&gt; &#39;server account,,,&#39; <br/>, login =&gt; &#39;root&#39; ) {<br/> my ( $rule, $candidate ) = .kv;<br/> ok ?PAccountDB.subparse( $candidate, :rule($rule) )<br/> , &quot;subrule $rule matches $candidate&quot;;<br/>}<br/><br/><br/>-- <br/>Marc Chantreux<br/>Universit&eacute; de Strasbourg, Direction Informatique<br/>14 Rue Ren&eacute; Descartes,<br/>67084 STRASBOURG CEDEX<br/>&#x260E;: 03.68.85.57.40<br/>http://unistra.fr<br/>&quot;Don&#39;t believe everything you read on the Internet&quot;<br/> -- Abraham Lincoln<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/07/msg1800.html Sat, 12 Jul 2014 09:41:39 +0000 Re: Diffrence between is and does in scope of overriding multi methods by Kamil Kułaga Hi Timo,<br/><br/>After I read your explanation and now it is even logical to use role<br/>punning in my app. In most cases I don&#39;t want to override this default<br/>behavior of method xyz but I would like to add new specific one. Only<br/>one class does opposite so it should be subclass of a role.<br/><br/>On Fri, Jun 27, 2014 at 3:25 PM, Timo Paulssen &lt;timo@wakelift.de&gt; wrote:<br/>&gt; On 27/06/14 10:07, Kamil Ku&#x142;aga wrote:<br/>&gt;&gt;<br/>&gt;&gt; Hi,<br/>&gt;&gt;<br/>&gt;&gt; I would like to ask for help in understanding difference between this<br/>&gt;&gt; code:<br/>&gt;&gt;<br/>&gt;&gt; use v6;<br/>&gt;&gt;<br/>&gt;&gt; role X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class X&quot;}<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt; class Y does X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt; say Y.new.xyz(1);<br/>&gt;&gt;<br/>&gt;&gt; $ perl6 tst.pl<br/>&gt;&gt; Ambiguous call to &#39;xyz&#39;; these signatures all match:<br/>&gt;&gt; :(Y: Any $a, *%_)<br/>&gt;&gt; :(Y: Any $a, *%_)<br/>&gt;&gt; in block at tst.pl:26<br/>&gt;&gt;<br/>&gt;&gt; And this code:<br/>&gt;&gt; use v6;<br/>&gt;&gt;<br/>&gt;&gt; class X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class X&quot;}<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt; class Y is X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt; say Y.new.xyz(1);<br/>&gt;&gt;<br/>&gt;&gt; $ perl6 tst.pl<br/>&gt;&gt; Class Y<br/>&gt;&gt; True<br/>&gt;&gt;<br/>&gt;&gt; It is hard to google such common words like is and does :)<br/>&gt;&gt;<br/>&gt;<br/>&gt; Hey Kamil,<br/>&gt;<br/>&gt; What happens when you &quot;does&quot; a role in a class, you &quot;mix in&quot; all the methods<br/>&gt; at the &quot;same level&quot;, basically as if you had copy-pasted the method<br/>&gt; declarations over. That&#39;s why you get the error that the call to xyz is<br/>&gt; ambiguous.<br/>&gt;<br/>&gt; When you &quot;is&quot; a class, you derive from it. That&#39;s why the multi method<br/>&gt; X::xyz gets &quot;overwritten&quot; by Y::xyz, as the signature is identical.<br/>&gt;<br/>&gt; At least that&#39;s my understanding.<br/>&gt;<br/>&gt; Btw, you can also &quot;is&quot; a role, in which case it will get &quot;punned&quot; into a<br/>&gt; class. That operation is equivalent to declaring a class with an empty body<br/>&gt; that &quot;does&quot; the given role. So in the upper example, with role X and class<br/>&gt; Y, you could &quot;is X&quot; and get the same behavior as in the lower example.<br/>&gt;<br/>&gt; Hope to help (and hope what I wrote is actually accurate)<br/>&gt; - Timo<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1799.html Fri, 27 Jun 2014 21:17:14 +0000 Re: Diffrence between is and does in scope of overriding multi methods by Elizabeth Mattijsen On 27 Jun 2014, at 09:25, Timo Paulssen &lt;timo@wakelift.de&gt; wrote:<br/>&gt; On 27/06/14 10:07, Kamil Ku&#x142;aga wrote:<br/>&gt;&gt; Hi,<br/>&gt;&gt; <br/>&gt;&gt; I would like to ask for help in understanding difference between this code:<br/>&gt;&gt; <br/>&gt;&gt; use v6;<br/>&gt;&gt; <br/>&gt;&gt; role X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class X&quot;}<br/>&gt;&gt; }<br/>&gt;&gt; <br/>&gt;&gt; class Y does X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/>&gt;&gt; }<br/>&gt;&gt; <br/>&gt;&gt; say Y.new.xyz(1);<br/>&gt;&gt; <br/>&gt;&gt; $ perl6 tst.pl<br/>&gt;&gt; Ambiguous call to &#39;xyz&#39;; these signatures all match:<br/>&gt;&gt; :(Y: Any $a, *%_)<br/>&gt;&gt; :(Y: Any $a, *%_)<br/>&gt;&gt; in block at tst.pl:26<br/>&gt;&gt; <br/>&gt;&gt; And this code:<br/>&gt;&gt; use v6;<br/>&gt;&gt; <br/>&gt;&gt; class X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class X&quot;}<br/>&gt;&gt; }<br/>&gt;&gt; <br/>&gt;&gt; class Y is X {<br/>&gt;&gt; multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/>&gt;&gt; }<br/>&gt;&gt; <br/>&gt;&gt; say Y.new.xyz(1);<br/>&gt;&gt; <br/>&gt;&gt; $ perl6 tst.pl<br/>&gt;&gt; Class Y<br/>&gt;&gt; True<br/>&gt;&gt; <br/>&gt;&gt; It is hard to google such common words like is and does :)<br/>&gt;&gt; <br/>&gt; <br/>&gt; Hey Kamil,<br/>&gt; <br/>&gt; What happens when you &quot;does&quot; a role in a class, you &quot;mix in&quot; all the methods at the &quot;same level&quot;, basically as if you had copy-pasted the method declarations over. That&#39;s why you get the error that the call to xyz is ambiguous.<br/>&gt; <br/>&gt; When you &quot;is&quot; a class, you derive from it. That&#39;s why the multi method X::xyz gets &quot;overwritten&quot; by Y::xyz, as the signature is identical.<br/>&gt; <br/>&gt; At least that&#39;s my understanding.<br/>&gt; <br/>&gt; Btw, you can also &quot;is&quot; a role, in which case it will get &quot;punned&quot; into a class. That operation is equivalent to declaring a class with an empty body that &quot;does&quot; the given role. So in the upper example, with role X and class Y, you could &quot;is X&quot; and get the same behavior as in the lower example.<br/>&gt; <br/>&gt; Hope to help (and hope what I wrote is actually accurate)<br/><br/>FWIW, I&rsquo;m not sure why the first case is actually a problem. I would expect this error if both X and Y were a role composed into a class Z.<br/><br/><br/>Liz<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1798.html Fri, 27 Jun 2014 14:03:12 +0000 Re: Diffrence between is and does in scope of overriding multi methods by Timo Paulssen On 27/06/14 10:07, Kamil Ku&#x142;aga wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; I would like to ask for help in understanding difference between this code:<br/>&gt;<br/>&gt; use v6;<br/>&gt;<br/>&gt; role X {<br/>&gt; multi method xyz(Any $a) {say &quot;Class X&quot;}<br/>&gt; }<br/>&gt;<br/>&gt; class Y does X {<br/>&gt; multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/>&gt; }<br/>&gt;<br/>&gt; say Y.new.xyz(1);<br/>&gt;<br/>&gt; $ perl6 tst.pl<br/>&gt; Ambiguous call to &#39;xyz&#39;; these signatures all match:<br/>&gt; :(Y: Any $a, *%_)<br/>&gt; :(Y: Any $a, *%_)<br/>&gt; in block at tst.pl:26<br/>&gt;<br/>&gt; And this code:<br/>&gt; use v6;<br/>&gt;<br/>&gt; class X {<br/>&gt; multi method xyz(Any $a) {say &quot;Class X&quot;}<br/>&gt; }<br/>&gt;<br/>&gt; class Y is X {<br/>&gt; multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/>&gt; }<br/>&gt;<br/>&gt; say Y.new.xyz(1);<br/>&gt;<br/>&gt; $ perl6 tst.pl<br/>&gt; Class Y<br/>&gt; True<br/>&gt;<br/>&gt; It is hard to google such common words like is and does :)<br/>&gt;<br/><br/>Hey Kamil,<br/><br/>What happens when you &quot;does&quot; a role in a class, you &quot;mix in&quot; all the <br/>methods at the &quot;same level&quot;, basically as if you had copy-pasted the <br/>method declarations over. That&#39;s why you get the error that the call to <br/>xyz is ambiguous.<br/><br/>When you &quot;is&quot; a class, you derive from it. That&#39;s why the multi method <br/>X::xyz gets &quot;overwritten&quot; by Y::xyz, as the signature is identical.<br/><br/>At least that&#39;s my understanding.<br/><br/>Btw, you can also &quot;is&quot; a role, in which case it will get &quot;punned&quot; into a <br/>class. That operation is equivalent to declaring a class with an empty <br/>body that &quot;does&quot; the given role. So in the upper example, with role X <br/>and class Y, you could &quot;is X&quot; and get the same behavior as in the lower <br/>example.<br/><br/>Hope to help (and hope what I wrote is actually accurate)<br/> - Timo<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1797.html Fri, 27 Jun 2014 13:26:05 +0000 Diffrence between is and does in scope of overriding multi methods by Kamil Kułaga Hi,<br/><br/>I would like to ask for help in understanding difference between this code:<br/><br/> use v6;<br/><br/> role X {<br/> multi method xyz(Any $a) {say &quot;Class X&quot;}<br/> }<br/><br/> class Y does X {<br/> multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/> }<br/><br/> say Y.new.xyz(1);<br/><br/> $ perl6 tst.pl<br/> Ambiguous call to &#39;xyz&#39;; these signatures all match:<br/> :(Y: Any $a, *%_)<br/> :(Y: Any $a, *%_)<br/> in block at tst.pl:26<br/><br/>And this code:<br/> use v6;<br/><br/> class X {<br/> multi method xyz(Any $a) {say &quot;Class X&quot;}<br/> }<br/><br/> class Y is X {<br/> multi method xyz(Any $a) {say &quot;Class Y&quot;}<br/> }<br/><br/> say Y.new.xyz(1);<br/><br/> $ perl6 tst.pl<br/> Class Y<br/> True<br/><br/>It is hard to google such common words like is and does :)<br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1796.html Fri, 27 Jun 2014 08:07:18 +0000 Re: Code execution during compilation by Kamil Kułaga I found it myself this won&#39;t work because when using multiple files<br/>and pir compilation INIT / END block parent class will be executed<br/>anyway.<br/><br/>Is there way to postone to runtime class attribute without doing it manually?<br/><br/>On Sun, Jun 15, 2014 at 10:34 PM, Kamil Ku&#x142;aga &lt;teodozjan@gmail.com&gt; wrote:<br/>&gt; Ok,<br/>&gt;<br/>&gt; I&#39;ve read SYN-04 Phasers and I think I should use INIT {} or END {}<br/>&gt;<br/>&gt; Are there any situations INIT {} / END {} will not postpone execution?<br/>&gt; Because in my case it is still executed during compilation<br/>&gt; https://github.com/teodozjan/lacuna-cookbuk/tree/init_problems<br/>&gt;<br/>&gt; On Sun, Jun 15, 2014 at 12:45 PM, Moritz Lenz &lt;moritz@faui2k3.org&gt; wrote:<br/>&gt;&gt; Hi,<br/>&gt;&gt;<br/>&gt;&gt; class and role bodies are executed at compile time, so yes, that&#39;s<br/>&gt;&gt; expected. The same thing happens in BEGIN blocks.<br/>&gt;&gt;<br/>&gt;&gt; (Actually, the case with roles is more complicated; iirc their bodies<br/>&gt;&gt; are executed at role application time, but in your example, &#39;class B<br/>&gt;&gt; does Xx&#39; runs at compile time, so the two are roughly equivalent).<br/>&gt;&gt;<br/>&gt;&gt; Cheers,<br/>&gt;&gt; Moritz<br/>&gt;&gt;<br/>&gt;&gt; On 06/15/2014 02:31 AM, Kamil Ku&#x142;aga wrote:<br/>&gt;&gt;&gt; Hi,<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; I got amazed little bit when this code:<br/>&gt;&gt;&gt; class A {<br/>&gt;&gt;&gt; method wow{say &quot;I&#39;m alive&quot;}<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; role Xx{<br/>&gt;&gt;&gt; my $th = A.wow;<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; class B does Xx {<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Started to live during compilation (also tried with ufo):<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; $ perl6 -o o.pir funnyrole.pl<br/>&gt;&gt;&gt; I&#39;m alive<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Is this expected or subject to change?<br/>&gt;&gt;&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; --<br/>&gt; Pozdrawiam<br/>&gt;<br/>&gt; Kamil Ku&#x142;aga<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1795.html Mon, 16 Jun 2014 12:17:01 +0000 Re: Code execution during compilation by Kamil Kułaga Ok,<br/><br/>I&#39;ve read SYN-04 Phasers and I think I should use INIT {} or END {}<br/><br/>Are there any situations INIT {} / END {} will not postpone execution?<br/>Because in my case it is still executed during compilation<br/>https://github.com/teodozjan/lacuna-cookbuk/tree/init_problems<br/><br/>On Sun, Jun 15, 2014 at 12:45 PM, Moritz Lenz &lt;moritz@faui2k3.org&gt; wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; class and role bodies are executed at compile time, so yes, that&#39;s<br/>&gt; expected. The same thing happens in BEGIN blocks.<br/>&gt;<br/>&gt; (Actually, the case with roles is more complicated; iirc their bodies<br/>&gt; are executed at role application time, but in your example, &#39;class B<br/>&gt; does Xx&#39; runs at compile time, so the two are roughly equivalent).<br/>&gt;<br/>&gt; Cheers,<br/>&gt; Moritz<br/>&gt;<br/>&gt; On 06/15/2014 02:31 AM, Kamil Ku&#x142;aga wrote:<br/>&gt;&gt; Hi,<br/>&gt;&gt;<br/>&gt;&gt; I got amazed little bit when this code:<br/>&gt;&gt; class A {<br/>&gt;&gt; method wow{say &quot;I&#39;m alive&quot;}<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt; role Xx{<br/>&gt;&gt; my $th = A.wow;<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; class B does Xx {<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt; Started to live during compilation (also tried with ufo):<br/>&gt;&gt;<br/>&gt;&gt; $ perl6 -o o.pir funnyrole.pl<br/>&gt;&gt; I&#39;m alive<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; Is this expected or subject to change?<br/>&gt;&gt;<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1794.html Sun, 15 Jun 2014 20:34:51 +0000 Re: Code execution during compilation by Moritz Lenz Hi,<br/><br/>class and role bodies are executed at compile time, so yes, that&#39;s<br/>expected. The same thing happens in BEGIN blocks.<br/><br/>(Actually, the case with roles is more complicated; iirc their bodies<br/>are executed at role application time, but in your example, &#39;class B<br/>does Xx&#39; runs at compile time, so the two are roughly equivalent).<br/><br/>Cheers,<br/>Moritz<br/><br/>On 06/15/2014 02:31 AM, Kamil Ku&#x142;aga wrote:<br/>&gt; Hi,<br/>&gt; <br/>&gt; I got amazed little bit when this code:<br/>&gt; class A {<br/>&gt; method wow{say &quot;I&#39;m alive&quot;}<br/>&gt; }<br/>&gt; <br/>&gt; role Xx{<br/>&gt; my $th = A.wow;<br/>&gt; }<br/>&gt; <br/>&gt; <br/>&gt; class B does Xx {<br/>&gt; }<br/>&gt; <br/>&gt; Started to live during compilation (also tried with ufo):<br/>&gt; <br/>&gt; $ perl6 -o o.pir funnyrole.pl<br/>&gt; I&#39;m alive<br/>&gt; <br/>&gt; <br/>&gt; Is this expected or subject to change?<br/>&gt; <br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1793.html Sun, 15 Jun 2014 10:45:35 +0000 Re: Code execution during compilation by Kamil Kułaga Of course ment<br/> perl6 --target=pir --output=o.pir funnyrole.pl<br/>but with same effect<br/>On Sun, Jun 15, 2014 at 2:31 AM, Kamil Ku&#x142;aga &lt;teodozjan@gmail.com&gt; wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; I got amazed little bit when this code:<br/>&gt; class A {<br/>&gt; method wow{say &quot;I&#39;m alive&quot;}<br/>&gt; }<br/>&gt;<br/>&gt; role Xx{<br/>&gt; my $th = A.wow;<br/>&gt; }<br/>&gt;<br/>&gt;<br/>&gt; class B does Xx {<br/>&gt; }<br/>&gt;<br/>&gt; Started to live during compilation (also tried with ufo):<br/>&gt;<br/>&gt; $ perl6 -o o.pir funnyrole.pl<br/>&gt; I&#39;m alive<br/>&gt;<br/>&gt;<br/>&gt; Is this expected or subject to change?<br/>&gt; --<br/>&gt; Pozdrawiam<br/>&gt;<br/>&gt; Kamil Ku&#x142;aga<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1792.html Sun, 15 Jun 2014 00:34:47 +0000 Code execution during compilation by Kamil Kułaga Hi,<br/><br/>I got amazed little bit when this code:<br/> class A {<br/> method wow{say &quot;I&#39;m alive&quot;}<br/> }<br/><br/> role Xx{<br/> my $th = A.wow;<br/> }<br/><br/><br/> class B does Xx {<br/> }<br/><br/>Started to live during compilation (also tried with ufo):<br/><br/> $ perl6 -o o.pir funnyrole.pl<br/> I&#39;m alive<br/><br/><br/>Is this expected or subject to change?<br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1791.html Sun, 15 Jun 2014 00:31:32 +0000 Re: Rewrite using map? Trasformation array into hash of hash by Kamil Kułaga Dear Timo.<br/><br/>So .categorize and .classify wil always end with list on leaves of<br/>produced tree? Ok I can live with that :)<br/><br/>On Sat, Jun 14, 2014 at 12:30 PM, &lt;timo@wakelift.de&gt; wrote:<br/>&gt; Dear Kamil,<br/>&gt;<br/>&gt;<br/>&gt; On 06/13/2014 10:24 PM, Kamil Ku&#x142;aga wrote:<br/>&gt;&gt; my %h = categorize({map {[.a , .b]}, $_},@array);<br/>&gt;<br/>&gt; I think the problem is that categorize will call your inner code block for<br/>&gt; every item in the @array. Then you map your {[.a, .b]} over that item, so<br/>&gt; you end up with a single-item list as a result. Could that be the problem?<br/>&gt;<br/>&gt; Cheers<br/>&gt; - Timo<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1790.html Sat, 14 Jun 2014 14:49:37 +0000 Re: Rewrite using map? Trasformation array into hash of hash by timo This is a multi-part message in MIME format.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1789.html Sat, 14 Jun 2014 10:30:20 +0000 Re: Rewrite using map? Trasformation array into hash of hash by Kamil Kułaga Dear Timo,<br/><br/>I&#39;m almost done with categorize. I stole similar example from rakudo<br/>tests but I can&#39;t get rid off array on end. If I remove from map []<br/>it stops working.<br/><br/>PS. I barely understand code I wrote anyway :)<br/><br/><br/>$ perl6 ~/xxxxxx.pl<br/>[A.new(a =&gt; &quot;a&quot;, b =&gt; &quot;22&quot;)]<br/>Reference<br/>A.new(a =&gt; &quot;a&quot;, b =&gt; &quot;22&quot;)<br/><br/><br/><br/>use v6;<br/><br/>class A { has $.a; has $.b };<br/>my @array = A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/> A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/> A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;);<br/><br/><br/>my %h = categorize({map {[.a , .b]}, $_},@array);<br/><br/>say %h&lt;a&gt;&lt;22&gt;.perl;<br/><br/>my %hash;<br/>for @array -&gt; $elem {<br/> %hash{$elem.a}{$elem.b} =$elem;<br/>}<br/><br/><br/>say &quot;Reference\n&quot; ~ %hash&lt;a&gt;&lt;22&gt;.perl;<br/><br/>On Fri, Jun 13, 2014 at 9:08 PM, &lt;timo@wakelift.de&gt; wrote:<br/>&gt; On 06/13/2014 08:15 PM, Kamil Ku&#x142;aga wrote:<br/>&gt;&gt; Ok got it. But solution is neither more readable nor faster (IMHO only<br/>&gt;&gt; -&gt; I didn&#39;t benchmark it)<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; class A { has $.a; has $.b };<br/>&gt;&gt; my @array = A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;);<br/>&gt;&gt;<br/>&gt;&gt; my %h = @array.map({<br/>&gt;&gt; my $var = .a;<br/>&gt;&gt; $var =&gt; %(@array.grep({.a eq $var}).map({.b =&gt; $_}))<br/>&gt;&gt; });<br/>&gt;&gt;<br/>&gt;&gt; say %h&lt;a&gt;.perl;<br/>&gt;&gt;<br/>&gt;&gt; my %hash;<br/>&gt;&gt; for @array -&gt; $elem {<br/>&gt;&gt; %hash{$elem.a}{$elem.b} =$elem;<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; say &quot;Reference\n&quot; ~ %hash&lt;a&gt;.perl;<br/>&gt;<br/>&gt; Dear Kamil,<br/>&gt;<br/>&gt; the method &quot;categorize&quot;, as specced in<br/>&gt; http://perlcabal.org/syn/S32/Containers.html#categorize will allow you<br/>&gt; to return a parcel from the &quot;categorization&quot; you provide (such as -&gt; $_<br/>&gt; { (.a, .b) }) and build a multi-leveled hash.<br/>&gt;<br/>&gt; Sadly, I wasn&#39;t able to make it work right away.<br/>&gt;<br/>&gt; Cheers,<br/>&gt; - Timo<br/>&gt;<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1788.html Fri, 13 Jun 2014 20:24:47 +0000 Re: Rewrite using map? Trasformation array into hash of hash by Elizabeth Mattijsen On 13 Jun 2014, at 12:36, Kamil Ku&#x142;aga &lt;teodozjan@gmail.com&gt; wrote:<br/>&gt; I was wondering whether following code can be rewritten using map/grep<br/>&gt; construct.<br/>&gt; <br/>&gt; <br/>&gt; class A {<br/>&gt; has $.a;<br/>&gt; has $.b;<br/>&gt; }<br/>&gt; <br/>&gt; <br/>&gt; my @array= (<br/>&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;)<br/>&gt; );<br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; my %hash;<br/>&gt; for @array -&gt; $elem {<br/>&gt; %hash{$elem.a}{$elem.b} =$elem;<br/>&gt; }<br/><br/>Not sure it makes much difference:<br/><br/>@array.map( { %hash{.a}{.b} = $_ } );<br/><br/><br/><br/>Liz http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1787.html Fri, 13 Jun 2014 20:05:44 +0000 Re: Rewrite using map? Trasformation array into hash of hash by timo On 06/13/2014 08:15 PM, Kamil Ku&#x142;aga wrote:<br/>&gt; Ok got it. But solution is neither more readable nor faster (IMHO only<br/>&gt; -&gt; I didn&#39;t benchmark it)<br/>&gt;<br/>&gt;<br/>&gt; class A { has $.a; has $.b };<br/>&gt; my @array = A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;);<br/>&gt;<br/>&gt; my %h = @array.map({<br/>&gt; my $var = .a;<br/>&gt; $var =&gt; %(@array.grep({.a eq $var}).map({.b =&gt; $_}))<br/>&gt; });<br/>&gt;<br/>&gt; say %h&lt;a&gt;.perl;<br/>&gt;<br/>&gt; my %hash;<br/>&gt; for @array -&gt; $elem {<br/>&gt; %hash{$elem.a}{$elem.b} =$elem;<br/>&gt; }<br/>&gt;<br/>&gt;<br/>&gt; say &quot;Reference\n&quot; ~ %hash&lt;a&gt;.perl;<br/><br/>Dear Kamil,<br/><br/>the method &quot;categorize&quot;, as specced in<br/>http://perlcabal.org/syn/S32/Containers.html#categorize will allow you<br/>to return a parcel from the &quot;categorization&quot; you provide (such as -&gt; $_<br/>{ (.a, .b) }) and build a multi-leveled hash.<br/><br/>Sadly, I wasn&#39;t able to make it work right away.<br/><br/>Cheers,<br/> - Timo<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1786.html Fri, 13 Jun 2014 19:08:28 +0000 Re: Rewrite using map? Trasformation array into hash of hash by Kamil Kułaga Ok got it. But solution is neither more readable nor faster (IMHO only<br/>-&gt; I didn&#39;t benchmark it)<br/><br/><br/>class A { has $.a; has $.b };<br/>my @array = A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/> A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/> A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;);<br/><br/>my %h = @array.map({<br/> my $var = .a;<br/> $var =&gt; %(@array.grep({.a eq $var}).map({.b =&gt; $_}))<br/> });<br/><br/>say %h&lt;a&gt;.perl;<br/><br/>my %hash;<br/>for @array -&gt; $elem {<br/> %hash{$elem.a}{$elem.b} =$elem;<br/>}<br/><br/><br/>say &quot;Reference\n&quot; ~ %hash&lt;a&gt;.perl;<br/><br/><br/>On Fri, Jun 13, 2014 at 4:49 PM, Kamil Ku&#x142;aga &lt;teodozjan@gmail.com&gt; wrote:<br/>&gt; Hi Tobias,<br/>&gt;<br/>&gt; Almost. At least at my rakudo creates list of hash of hash and loses<br/>&gt; data while converting to hash:<br/>&gt;<br/>&gt; (&quot;a&quot; =&gt; &quot;11&quot; =&gt; A.new(a =&gt; &quot;a&quot;, b =&gt; &quot;11&quot;), &quot;a&quot; =&gt; &quot;22&quot; =&gt; A.new(a =&gt;<br/>&gt; &quot;a&quot;, b =&gt; &quot;22&quot;), &quot;v&quot; =&gt; &quot;33&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;33&quot;), &quot;w&quot; =&gt;<br/>&gt; &quot;44&quot; =&gt; A.new(a =&gt; &quot;w&quot;, b =&gt; &quot;44&quot;), &quot;v&quot; =&gt; &quot;55&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b<br/>&gt; =&gt; &quot;55&quot;)).list.item<br/>&gt;<br/>&gt;<br/>&gt; On Fri, Jun 13, 2014 at 2:30 PM, Tobias Leich &lt;email@froggs.de&gt; wrote:<br/>&gt;&gt; Hi, like that?<br/>&gt;&gt;<br/>&gt;&gt; class A { has $.a; has $.b };<br/>&gt;&gt; my @array = A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;);<br/>&gt;&gt;<br/>&gt;&gt; say @array.map({ .a =&gt; .b =&gt; $_ })<br/>&gt;&gt;<br/>&gt;&gt; OUTPUT&laquo;&quot;a&quot; =&gt; &quot;11&quot; =&gt; A.new(a =&gt; &quot;a&quot;, b =&gt; &quot;11&quot;) &quot;a&quot; =&gt; &quot;22&quot; =&gt; A.new(a<br/>&gt;&gt; =&gt; &quot;a&quot;, b =&gt; &quot;22&quot;) &quot;v&quot; =&gt; &quot;33&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;33&quot;) &quot;w&quot; =&gt; &quot;44&quot;<br/>&gt;&gt; =&gt; A.new(a =&gt; &quot;w&quot;, b =&gt; &quot;44&quot;) &quot;v&quot; =&gt; &quot;55&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;55&quot;)&#x2424;&raquo;<br/>&gt;&gt;<br/>&gt;&gt; Am 13.06.2014 12:36, schrieb Kamil Ku&#x142;aga:<br/>&gt;&gt;&gt; Hi,<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; I was wondering whether following code can be rewritten using map/grep<br/>&gt;&gt;&gt; construct.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; class A {<br/>&gt;&gt;&gt; has $.a;<br/>&gt;&gt;&gt; has $.b;<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; my @array= (<br/>&gt;&gt;&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt;&gt;&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt;&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt;&gt;&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt;&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;)<br/>&gt;&gt;&gt; );<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; my %hash;<br/>&gt;&gt;&gt; for @array -&gt; $elem {<br/>&gt;&gt;&gt; %hash{$elem.a}{$elem.b} =$elem;<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; say %hash.perl;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Can it?<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; --<br/>&gt; Pozdrawiam<br/>&gt;<br/>&gt; Kamil Ku&#x142;aga<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1785.html Fri, 13 Jun 2014 18:15:15 +0000 Re: Rewrite using map? Trasformation array into hash of hash by Kamil Kułaga Hi Tobias,<br/><br/>Almost. At least at my rakudo creates list of hash of hash and loses<br/>data while converting to hash:<br/><br/>(&quot;a&quot; =&gt; &quot;11&quot; =&gt; A.new(a =&gt; &quot;a&quot;, b =&gt; &quot;11&quot;), &quot;a&quot; =&gt; &quot;22&quot; =&gt; A.new(a =&gt;<br/>&quot;a&quot;, b =&gt; &quot;22&quot;), &quot;v&quot; =&gt; &quot;33&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;33&quot;), &quot;w&quot; =&gt;<br/>&quot;44&quot; =&gt; A.new(a =&gt; &quot;w&quot;, b =&gt; &quot;44&quot;), &quot;v&quot; =&gt; &quot;55&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b<br/>=&gt; &quot;55&quot;)).list.item<br/><br/><br/>On Fri, Jun 13, 2014 at 2:30 PM, Tobias Leich &lt;email@froggs.de&gt; wrote:<br/>&gt; Hi, like that?<br/>&gt;<br/>&gt; class A { has $.a; has $.b };<br/>&gt; my @array = A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;);<br/>&gt;<br/>&gt; say @array.map({ .a =&gt; .b =&gt; $_ })<br/>&gt;<br/>&gt; OUTPUT&laquo;&quot;a&quot; =&gt; &quot;11&quot; =&gt; A.new(a =&gt; &quot;a&quot;, b =&gt; &quot;11&quot;) &quot;a&quot; =&gt; &quot;22&quot; =&gt; A.new(a<br/>&gt; =&gt; &quot;a&quot;, b =&gt; &quot;22&quot;) &quot;v&quot; =&gt; &quot;33&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;33&quot;) &quot;w&quot; =&gt; &quot;44&quot;<br/>&gt; =&gt; A.new(a =&gt; &quot;w&quot;, b =&gt; &quot;44&quot;) &quot;v&quot; =&gt; &quot;55&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;55&quot;)&#x2424;&raquo;<br/>&gt;<br/>&gt; Am 13.06.2014 12:36, schrieb Kamil Ku&#x142;aga:<br/>&gt;&gt; Hi,<br/>&gt;&gt;<br/>&gt;&gt; I was wondering whether following code can be rewritten using map/grep<br/>&gt;&gt; construct.<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; class A {<br/>&gt;&gt; has $.a;<br/>&gt;&gt; has $.b;<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; my @array= (<br/>&gt;&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt;&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;)<br/>&gt;&gt; );<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; my %hash;<br/>&gt;&gt; for @array -&gt; $elem {<br/>&gt;&gt; %hash{$elem.a}{$elem.b} =$elem;<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; say %hash.perl;<br/>&gt;&gt;<br/>&gt;&gt; Can it?<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;<br/><br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1784.html Fri, 13 Jun 2014 14:49:58 +0000 Re: Rewrite using map? Trasformation array into hash of hash by Tobias Leich Hi, like that?<br/><br/>class A { has $.a; has $.b };<br/>my @array = A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/> A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/> A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;);<br/><br/>say @array.map({ .a =&gt; .b =&gt; $_ })<br/><br/>OUTPUT&laquo;&quot;a&quot; =&gt; &quot;11&quot; =&gt; A.new(a =&gt; &quot;a&quot;, b =&gt; &quot;11&quot;) &quot;a&quot; =&gt; &quot;22&quot; =&gt; A.new(a<br/>=&gt; &quot;a&quot;, b =&gt; &quot;22&quot;) &quot;v&quot; =&gt; &quot;33&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;33&quot;) &quot;w&quot; =&gt; &quot;44&quot;<br/>=&gt; A.new(a =&gt; &quot;w&quot;, b =&gt; &quot;44&quot;) &quot;v&quot; =&gt; &quot;55&quot; =&gt; A.new(a =&gt; &quot;v&quot;, b =&gt; &quot;55&quot;)&#x2424;&raquo;<br/><br/>Am 13.06.2014 12:36, schrieb Kamil Ku&#x142;aga:<br/>&gt; Hi,<br/>&gt;<br/>&gt; I was wondering whether following code can be rewritten using map/grep<br/>&gt; construct.<br/>&gt;<br/>&gt;<br/>&gt; class A {<br/>&gt; has $.a;<br/>&gt; has $.b;<br/>&gt; }<br/>&gt;<br/>&gt;<br/>&gt; my @array= (<br/>&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/>&gt; A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/>&gt; A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/>&gt; A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;)<br/>&gt; );<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; my %hash;<br/>&gt; for @array -&gt; $elem {<br/>&gt; %hash{$elem.a}{$elem.b} =$elem;<br/>&gt; }<br/>&gt;<br/>&gt;<br/>&gt; say %hash.perl;<br/>&gt;<br/>&gt; Can it?<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1783.html Fri, 13 Jun 2014 12:30:26 +0000 Rewrite using map? Trasformation array into hash of hash by Kamil Kułaga Hi,<br/><br/>I was wondering whether following code can be rewritten using map/grep<br/>construct.<br/><br/><br/> class A {<br/> has $.a;<br/> has $.b;<br/> }<br/><br/><br/> my @array= (<br/> A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;11&#39;),<br/> A.new(a=&gt;&#39;a&#39;, b=&gt;&#39;22&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;33&#39;),<br/> A.new(a=&gt;&#39;w&#39;, b=&gt;&#39;44&#39;),<br/> A.new(a=&gt;&#39;v&#39;, b=&gt;&#39;55&#39;)<br/> );<br/><br/><br/><br/> my %hash;<br/> for @array -&gt; $elem {<br/> %hash{$elem.a}{$elem.b} =$elem;<br/> }<br/><br/><br/> say %hash.perl;<br/><br/>Can it?<br/><br/><br/>-- <br/>Pozdrawiam<br/><br/>Kamil Ku&#x142;aga<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1782.html Fri, 13 Jun 2014 10:37:06 +0000 Re: perl6 hackathon at fpw'14? by Tadeusz Sośnierz On 06/11/2014 05:35 PM, Marc Chantreux wrote:<br/>&gt; * s-exml (which is about writting a grammar in perl6 or NQP),<br/>&gt; a s-expression based dialect to generate xml:<br/>&gt;<br/>&gt; (body :lang(fr) :editable<br/>&gt; (div :class(abstract important) s-expr is way more readable and<br/>&gt; editable than xml and more saner than a builder based on nested<br/>&gt; datastructures because<br/>&gt; (ul<br/>&gt; (li i can compile and collapse the structure as the<br/>&gt; longest string as possible)<br/>&gt; (li this dialect is even more readable than the<br/>&gt; equivalent perl6 datastructure)<br/>&gt; (li parentheses are at the right place: it is soooo easy<br/>&gt; to edit it with a decent editor (&#39;vi for example) )<br/>&gt; (li this is (a :href(http://acmeism.org/) acmeic), i<br/>&gt; really think it&#39;s important for a template system)<br/>&gt; )<br/>&gt; )<br/>&gt; )<br/><br/>This looks like fun to me :)<br/><br/><br/>&gt; want to help for one of this projets? have your own one in perl6? please<br/>&gt; tell me: we&#39;ll hack together.<br/><br/><br/>Best regards,<br/>tadzik<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1781.html Wed, 11 Jun 2014 21:40:16 +0000 perl6 hackathon at fpw'14? by Marc Chantreux hello, <br/><br/>i would like to spend some time on perl6 during the next french perl<br/>workshop http://journeesperl.fr/fpw2014/event/1567.<br/><br/>my &quot;excuses&quot; to write perl6 code are called <br/><br/><br/>* a marc::mir port (which is about writting bindings for JVM and/or<br/> moarVM), a set of helpers to process MARC library records.<br/>* s-exml (which is about writting a grammar in perl6 or NQP),<br/> a s-expression based dialect to generate xml:<br/><br/> (body :lang(fr) :editable<br/> (div :class(abstract important) s-expr is way more readable and<br/> editable than xml and more saner than a builder based on nested<br/> datastructures because <br/> (ul<br/> (li i can compile and collapse the structure as the<br/> longest string as possible)<br/> (li this dialect is even more readable than the<br/> equivalent perl6 datastructure)<br/> (li parentheses are at the right place: it is soooo easy<br/> to edit it with a decent editor (&#39;vi for example) )<br/> (li this is (a :href(http://acmeism.org/) acmeic), i<br/> really think it&#39;s important for a template system) <br/> ) <br/> ) <br/> )<br/><br/>want to help for one of this projets? have your own one in perl6? please<br/>tell me: we&#39;ll hack together. <br/><br/>regards<br/><br/>-- <br/>Marc Chantreux (eiro on github and freenode)<br/>http://eiro.github.com/<br/>http://eiro.github.com/atom.xml<br/>&quot;Don&#39;t believe everything you read on the Internet&quot;<br/> -- Abraham Lincoln<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1780.html Wed, 11 Jun 2014 15:36:03 +0000 Re: Perl6 and wxwidgets by Erik Colson Hi All,<br/><br/>Thanks for the very fast information provided. As this is not an easy project I&rsquo;ll dig into it later on, if I&rsquo;m feeling confident enough&hellip;<br/><br/>best<br/>--<br/>erik colson<br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1779.html Mon, 09 Jun 2014 09:19:49 +0000 Re: Perl6 and wxwidgets by Brandon Allbery On Sun, Jun 8, 2014 at 6:54 AM, Erik Colson &lt;eco@ecocode.net&gt; wrote:<br/><br/>&gt; Is it possible to use an external C-library like wxwidgets from<br/>&gt; perl6/moarvm ?<br/>&gt; If so, is there any doc how this can be achieved ?<br/>&gt;<br/><br/>wxwidgets may actually be a bit difficult, since it&#39;s not a C library. It&#39;s<br/>C++, and that is famously difficult to use via system linkage unless you<br/>write the linkage in C++ exporting C interfaces with the `extern &quot;C&quot;`<br/>mechanism.<br/><br/>-- <br/>brandon s allbery kf8nh sine nomine associates<br/>allbery.b@gmail.com ballbery@sinenomine.net<br/>unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1778.html Sun, 08 Jun 2014 17:21:43 +0000 Re: Perl6 and wxwidgets by Tobias Leich GTK::Simple is a recent example of how to make these bindings:<br/>https://github.com/perl6/gtk-simple/<br/><br/>Am 08.06.2014 12:56, schrieb Moritz Lenz:<br/>&gt; Hallo Erik,<br/>&gt;<br/>&gt; On 08.06.2014 12:54, Erik Colson wrote:<br/>&gt;&gt; Is it possible to use an external C-library like wxwidgets from perl6/moarvm ?<br/>&gt;&gt; If so, is there any doc how this can be achieved ?<br/>&gt; It is, through the NativeCall library: https://github.com/jnthn/zavolaj/<br/>&gt;<br/>&gt; Cheers,<br/>&gt; Moritz<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1777.html Sun, 08 Jun 2014 10:59:17 +0000 Re: Perl6 and wxwidgets by timo <br/>On 06/08/2014 12:54 PM, Erik Colson wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; Is it possible to use an external C-library like wxwidgets from perl6/moarvm ?<br/>&gt; If so, is there any doc how this can be achieved ?<br/>&gt;<br/>&gt; Thanks<br/>&gt; --<br/>&gt; erik colson<br/>Hello Erik,<br/><br/>We have a Module in the ecosystem called NativeCall (lives on github in<br/>a repository named zavolaj), that makes it quite simple to bind C<br/>libraries. This works across jvm, moar and parrot.<br/><br/>For a few examples, check out these projects:<br/><br/>https://github.com/avuserow/perl6-audio-taglib-simple/<br/>https://github.com/avuserow/perl6-compress-snappy/<br/>https://github.com/retupmoca/P6-Compress-Zlib-Raw/<br/>https://github.com/dagurval/perl6-gd-raw/<br/>https://github.com/perl6/gtk-simple/<br/>https://github.com/mrhdias/perl6-Imlib2/<br/><br/>Hope to help!<br/> - Timo<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1776.html Sun, 08 Jun 2014 10:59:15 +0000 Re: Perl6 and wxwidgets by Moritz Lenz Hallo Erik,<br/><br/>On 08.06.2014 12:54, Erik Colson wrote:<br/>&gt; Is it possible to use an external C-library like wxwidgets from perl6/moarvm ?<br/>&gt; If so, is there any doc how this can be achieved ?<br/><br/>It is, through the NativeCall library: https://github.com/jnthn/zavolaj/<br/><br/>Cheers,<br/>Moritz<br/> http://www.nntp.perl.org/group/perl.perl6.users/2014/06/msg1775.html Sun, 08 Jun 2014 10:56:59 +0000