perl.perl6.users http://www.nntp.perl.org/group/perl.perl6.users/ ... Copyright 1998-2009 perl.org Sun, 05 Jul 2009 07:02:31 +0000 ask@perl.org Re: negative index in perl6 array by Matthew Walton On Sat, Jun 20, 2009 at 12:07 PM, Chas. Owens&lt;chas.owens@gmail.com&gt; wrote:<br/>&gt; Hmm, I can&#39;t get [user-defined array indexes][1] working, and those<br/>&gt; are a prerequisite for mixing subscripts (you can&#39;t mix normal and<br/>&gt; user-defined indexes if you can&#39;t create user-defined indexes). &nbsp;I<br/>&gt; took a quick look at the tests and couldn&#39;t even find a test for<br/>&gt; user-defined array indexes.<br/>&gt;<br/>&gt; [1] : http://perlcabal.org/syn/S09.html#User-defined_array_indexing<br/><br/>That means it&#39;s not implemented yet, unfortunately.<br/><br/>By the way, if you have trouble remembering that negative indexes for<br/>arrays are now *-n, recall that the * is generally called &#39;whatever&#39;,<br/>so it&#39;s &#39;whatever - 1&#39;, and the &#39;whatever&#39; in this case fills in to be<br/>&#39;however many things are in the array, the precise value of which I<br/>really don&#39;t care about&#39;.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1124.html Tue, 23 Jun 2009 23:24:31 +0000 Re: negative index in perl6 array by Chas. Owens On Sat, Jun 20, 2009 at 02:49, Aruna Goke&lt;myklass@gmail.com&gt; wrote:<br/>&gt; Chas. Owens wrote:<br/>&gt;&gt;<br/>&gt;&gt; On Sat, Jun 20, 2009 at 00:58, Aruna Goke&lt;myklass@gmail.com&gt; wrote:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; is negative index not allowed in perl6?<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; i tried<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; my @test = (1 .. 20);<br/>&gt;&gt;&gt; @test[-1].say;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; OUTPUT<br/>&gt;&gt;&gt; Use of uninitialized value<br/>&gt;&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; You have to say<br/>&gt;&gt;<br/>&gt;&gt; @test[*-1].say;<br/>&gt;&gt;<br/>&gt;&gt; now<br/>&gt;&gt;<br/>&gt;&gt; http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts<br/>&gt;&gt;<br/>&gt; Thanks Chas,<br/>&gt;<br/>&gt; however, i have been trying to run the example of Mixing subscripts under<br/>&gt; S09.<br/>&gt;<br/>&gt; can you give me an example of using the Mixing subscripts?<br/>&gt;<br/>&gt; goksie<br/>&gt;<br/><br/>Hmm, I can&#39;t get [user-defined array indexes][1] working, and those<br/>are a prerequisite for mixing subscripts (you can&#39;t mix normal and<br/>user-defined indexes if you can&#39;t create user-defined indexes). I<br/>took a quick look at the tests and couldn&#39;t even find a test for<br/>user-defined array indexes.<br/><br/>[1] : http://perlcabal.org/syn/S09.html#User-defined_array_indexing<br/><br/>-- <br/>Chas. Owens<br/>wonkden.net<br/>The most important skill a programmer can have is the ability to read.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1123.html Sat, 20 Jun 2009 04:08:11 +0000 Re: negative index in perl6 array by Aruna Goke Chas. Owens wrote:<br/>&gt; On Sat, Jun 20, 2009 at 00:58, Aruna Goke&lt;myklass@gmail.com&gt; wrote:<br/>&gt;&gt; is negative index not allowed in perl6?<br/>&gt;&gt;<br/>&gt;&gt; i tried<br/>&gt;&gt;<br/>&gt;&gt; my @test = (1 .. 20);<br/>&gt;&gt; @test[-1].say;<br/>&gt;&gt;<br/>&gt;&gt; OUTPUT<br/>&gt;&gt; Use of uninitialized value<br/>&gt;&gt;<br/>&gt; <br/>&gt; You have to say<br/>&gt; <br/>&gt; @test[*-1].say;<br/>&gt; <br/>&gt; now<br/>&gt; <br/>&gt; http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts<br/>&gt; <br/>Thanks Chas,<br/><br/>however, i have been trying to run the example of Mixing subscripts <br/>under S09.<br/><br/>can you give me an example of using the Mixing subscripts?<br/><br/>goksie<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1122.html Fri, 19 Jun 2009 23:52:30 +0000 Re: negative index in perl6 array by Chas. Owens On Sat, Jun 20, 2009 at 00:58, Aruna Goke&lt;myklass@gmail.com&gt; wrote:<br/>&gt; is negative index not allowed in perl6?<br/>&gt;<br/>&gt; i tried<br/>&gt;<br/>&gt; my @test = (1 .. 20);<br/>&gt; @test[-1].say;<br/>&gt;<br/>&gt; OUTPUT<br/>&gt; Use of uninitialized value<br/>&gt;<br/><br/>You have to say<br/><br/>@test[*-1].say;<br/><br/>now<br/><br/>http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts<br/><br/>-- <br/>Chas. Owens<br/>wonkden.net<br/>The most important skill a programmer can have is the ability to read.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1121.html Fri, 19 Jun 2009 22:13:32 +0000 negative index in perl6 array by Aruna Goke is negative index not allowed in perl6?<br/><br/>i tried<br/><br/>my @test = (1 .. 20);<br/>@test[-1].say;<br/><br/>OUTPUT<br/>Use of uninitialized value<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1120.html Fri, 19 Jun 2009 22:01:55 +0000 Rakudo Perl 6 development release #18 ("Pittsburgh") by Patrick R. Michaud <br/>On behalf of the Rakudo development team, I&#39;m pleased to announce<br/>the June 2009 development release of Rakudo Perl #18 &quot;Pittsburgh&quot;.<br/>Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine [1].<br/>The tarball for the June 2009 release is available from<br/>http://github.com/rakudo/rakudo/downloads .<br/><br/>Due to the continued rapid pace of Rakudo development and the<br/>frequent addition of new Perl 6 features and bugfixes, we continue<br/>to recommend that people wanting to use or work with Rakudo obtain<br/>the latest source directly from the main repository at github.<br/>More details are available at http://rakudo.org/how-to-get-rakudo .<br/><br/>Rakudo Perl follows a monthly release cycle, with each release code named<br/>after a Perl Mongers group. This release is named &quot;Pittsburgh&quot;, which<br/>is the host for YAPC|10 (YAPC::NA 2009) [2] and the Parrot Virtual Machine<br/>Workshop [3]. Pittsburgh.pm has also sponsored hackathons for Rakudo <br/>Perl as part of the 2008 Pittsburgh Perl Workshop [4].<br/><br/>In this release of Rakudo Perl, we&#39;ve focused our efforts on refactoring<br/>many of Rakudo&#39;s internals; these refactors improve performance, <br/>bring us closer to the Perl 6 specification, operate more cleanly<br/>with Parrot, and provide a stronger foundation for features to be<br/>implemented in the near future. Some of the specific major changes<br/>and improvements in this release include:<br/><br/>* Rakudo is now passing 11,536 spectests, an increase of 194<br/> passing tests since the May 2009 release. With this release<br/> Rakudo is now passing 68% of the available spectest suite.<br/><br/>* Method dispatch has been substantially refactored; the new dispatcher<br/> is significantly faster and follows the Perl 6 specification more<br/> closely.<br/><br/>* Object initialization via the BUILD and CREATE (sub)methods is<br/> substantially improved.<br/><br/>* All return values are now type checked (previously only explicit<br/> &#39;return&#39; statements would perform type checking).<br/><br/>* String handling is significantly improved: fewer Unicode-related<br/> bugs exist, and parsing speed is greatly improved for some programs <br/> containing characters in the Latin-1 set.<br/><br/>* The IO .lines and .get methods now follow the specification more closely.<br/><br/>* User-defined operators now also receive some of their associated <br/> meta variants.<br/><br/>* The &#39;is export&#39; trait has been improved; more builtin functions<br/> and methods can be written in Perl 6 instead of PIR.<br/><br/>* Many Parrot changes have improved performance and reduced overall<br/> memory leaks (although there&#39;s still much more improvement needed).<br/><br/>The development team thanks all of our contributors and sponsors for<br/>making Rakudo Perl possible. If you would like to contribute,<br/>see http://rakudo.org/how-to-help , ask on the perl6-compiler@perl.org<br/>mailing list, or ask on IRC #perl6 on freenode.<br/><br/>The next release of Rakudo (#19) is scheduled for July 23, 2009.<br/>A list of the other planned release dates and codenames for 2009 is<br/>available in the &quot;docs/release_guide.pod&quot; file. In general, Rakudo<br/>development releases are scheduled to occur two days after each<br/>Parrot monthly release. Parrot releases the third Tuesday of each month.<br/><br/>Have fun!<br/><br/>References:<br/>[1] Parrot, http://parrot.org/<br/>[2] YAPC|10 http://yapc10.org/yn2009/<br/>[3] Parrot Virtual Machine Workshop, http://yapc10.org/yn2009/talk/2045<br/>[4] Pittsburgh Perl Workshop, http://pghpw.org/ppw2008/<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1119.html Thu, 18 Jun 2009 22:26:20 +0000 [proto] installing a module if PARROT_DIR is a symlink by Moritz Lenz Since viklund++ added proto support to JSON yesterday, I wanted to try<br/>it - and I found some problem that I don&#39;t know how to fix.<br/><br/>This is how my setup looks:<br/>rakudo (bleed) lives in ~/rakudo/. Parrot lives in ~/rakudo/parrot/,<br/>which is a symlink to ~/tmp/parrot-all/<br/>~/bin/ is in $PATH, and ~/bin/perl6 is a symlink to ~/rakudo/perl6.<br/><br/>Now I cloned JSON, and tried this:<br/><br/>moritz@trudi:~/src/json&gt;perl6 Configure<br/><br/>Configure.pm is preparing to make your Makefile.<br/><br/>Found a PARROT_DIR to be /home/moritz/tmp/parrot-all<br/>but there is no Rakudo nearby. Please contact the proto people.<br/><br/>Setting PARROT_DIR explicitly to ~/rakudo/parrot leads to exactly the<br/>same message.<br/><br/>So, what should I do?<br/>I don&#39;t want proto to manage my rakudo or parrot installation for me,<br/>just the module build.<br/><br/>Cheers,<br/>Moritz<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1118.html Sat, 13 Jun 2009 05:02:34 +0000 The Josephus Problem by Daniel Carrera Hello,<br/><br/>Some list members may be interested in this blog post:<br/><br/>http://daniel.carrera.bz/2009/06/perl-6-and-the-josephus-problem/<br/><br/>I use the Josephus Problem to compare the OOP syntax of Perl 6, Python <br/>and Ruby. It turns out that Perl 6 is *a bit* shorter and no less clear. <br/>The point is that one can no longer say that Perl&#39;s OOP is awkward.<br/><br/>I put a lot of effort in writing the code the same way in all languages <br/>and I tried very hard to avoid any bias.<br/><br/>Cheers,<br/>Daniel.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1117.html Fri, 12 Jun 2009 09:05:32 +0000 Re: the file slurping is not working by Smylers Tom Christiansen writes:<br/><br/>&gt; Larry wrote:<br/>&gt; <br/>&gt; &gt; But we&#39;re trying very hard to get rid of most such special cases in<br/>&gt; &gt; Perl 6. Usually we can get the recommended Perl 6 code to just DWYM<br/>&gt; &gt; as a fallout of the general semantics,<br/>&gt; <br/>&gt; Oh. You mean like for directories containing a file whose name is the<br/>&gt; 1-char string, &quot;0&quot;, and that file pre-emptively terminating a readdir<br/>&gt; loop the way it used to.<br/><br/>I can&#39;t find it in the spec (link anybody?) but I&#39;d expect the return<br/>value to be something which stringifies to &quot;0&quot; but boolifies to false,<br/>meaning it won&#39;t terminate the loop.<br/><br/>That way we get the intuitive behaviour, but don&#39;t need a special case.<br/>And the general mechanism used to make this work is something available<br/>for all Perl programs to take advantage of, not an exception that<br/>requires baking into the core language internals.<br/><br/>Smylers<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1116.html Wed, 10 Jun 2009 09:32:32 +0000 Re: rakudo-current loop 2-3 orders of magnitude slower than perl5? by Timothy S. Nelson On Thu, 4 Jun 2009, Fagyal Csongor wrote:<br/><br/>&gt; increase in the number of new Perl6ers at around &lt; 100x slower. (That, and <br/>&gt; the 10 &quot;most important&quot; Perl5 CPAN modules ported to Perl6 :))<br/><br/> Strangely enough, I was working on a list of things like this at one <br/>point. I&#39;ll format it up a bit, and include it below.<br/><br/>--------------------------------------------<br/><br/>Category 1: Popular module types not covered by the Perl6 specs<br/>- Tree/Datapath API module type (include DBI access, PathTools, maybe URI)<br/>- Template module type (ie. HTML::Mason/Text::Template)<br/>- Protocol module type requires:<br/> - Grammars<br/> - Event-loop framework (see below)<br/> - Finite state machine<br/><br/>Category 2: Other popular purposes that aren&#39;t already covered by perl <br/>features (eg. grammars or testing):<br/>- Images (ie. GD)<br/>- Archive/Encoding/Encryption<br/>- Interfaces for specific software<br/><br/><br/>Category 3: Covered well by the specs<br/>- Time/Date -- see Temporal.pod<br/><br/>Category 4: Covered sketchily by the specs<br/>- Event-loop framework -- will go in S17<br/> - See POE-basic, AnyEvent, etc.<br/><br/>--------------------------------------------<br/><br/> I generated the ideas in the above list by looking at some list of the <br/>top 100 Perl5 modules (Phalanx or something), and trying to extract out what I <br/>thought the common themes were. But I haven&#39;t explained some of them very <br/>well.<br/><br/> I&#39;ve gone on enough about the Tree/Datapath stuff often enough that <br/>those who followed it will have some idea of what I&#39;m on about, but if not, <br/>let me know.<br/><br/> The &quot;Protocol&quot; module mentioned is an idea for a suite of modules like <br/>Perl5&#39;s Net::Cmd, but better; inbuilt stuff for dealing with some of the basic <br/>kinds of protocol, whether basic call/response like POP, or numbered responses <br/>like SMTP, or the xAP style format used in IMAP and ACAP, or the MIME-encoded <br/>stuff in HTTP.<br/><br/> Hopefully most of the rest should be fairly obvious, but if not, let <br/>me know.<br/><br/> HTH,<br/><br/><br/>---------------------------------------------------------------------<br/>| Name: Tim Nelson | Because the Creator is, |<br/>| E-mail: wayland@wayland.id.au | I am |<br/>---------------------------------------------------------------------<br/><br/>----BEGIN GEEK CODE BLOCK----<br/>Version 3.12<br/>GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- <br/>PE(+) Y+&gt;++ PGP-&gt;+++ R(+) !tv b++ DI++++ D G+ e++&gt;++++ h! y-<br/>-----END GEEK CODE BLOCK-----<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1115.html Tue, 09 Jun 2009 05:51:20 +0000 Re: RPN calculator in Perl 6 by Daniel Ruoso Em S&aacute;b, 2009-06-06 &agrave;s 19:51 +0200, Daniel Carrera escreveu:<br/>&gt; Daniel Ruoso wrote:<br/>&gt; &gt; Yes... that&#39;s what wasn&#39;t implemented... But now it is ;)<br/>&gt; &gt; http://sial.org/pbot/37085<br/>&gt; Close, but...<br/>&gt; % perl6 rpn.pl &quot;5 4 + 3 / 5 3 - *&quot;<br/>&gt; -6<br/>&gt; That should be a positive 6.<br/><br/>Fixed now!<br/>http://sial.org/pbot/37088<br/><br/>(with a op trace included, so one can see what&#39;s happening...)<br/><br/>&gt; Are you planning to write a post explaining how your program works?<br/><br/>Maybe, but if you want to beat me to it, feel free ;)<br/><br/>&gt; I figure that the explanation is as useful as the example. I sure<br/>&gt; spent a lot of time writing the blog post.<br/><br/>I&#39;m not sure I&#39;ll have the time to write it soon, but it will certainly<br/>be on my list, unless you kindly post about it first ;)<br/><br/>daniel<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1114.html Mon, 08 Jun 2009 10:16:30 +0000 Re: RPN calculator in Perl 6 by Daniel Ruoso Em S&aacute;b, 2009-06-06 &agrave;s 18:22 +0200, Daniel Carrera escreveu:<br/>&gt; Daniel Ruoso wrote:<br/>&gt; &gt; er... that&#39;s because I didn&#39;t tried to implement it... but it<br/>&gt; certainly<br/>&gt; &gt; is possible to, just by declaring the :(@a, Num $a) variant...<br/>&gt; Well, * is implemented, so I guess you are talking about complex <br/>&gt; expressions.<br/><br/>Yes... that&#39;s what wasn&#39;t implemented... But now it is ;)<br/><br/>http://sial.org/pbot/37085<br/><br/>daniel<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1113.html Mon, 08 Jun 2009 09:59:36 +0000 Re: RPN calculator in Perl 6 by Daniel Ruoso Em S&aacute;b, 2009-06-06 &agrave;s 14:06 +0200, Daniel Carrera escreveu:<br/>&gt; I just wrote a blog post showing how to make a reverse polish notation <br/>&gt; calculator in Perl 6. In the process I show some of Perl 6&#39;s grammar <br/>&gt; features.<br/><br/>TIMTOWTDI ;)<br/><br/>http://sial.org/pbot/37075<br/><br/>daniel<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1112.html Mon, 08 Jun 2009 09:31:17 +0000 Re: RPN calculator in Perl 6 by Geoffrey Broadwell On Sat, 2009-06-06 at 13:18 -0300, Daniel Ruoso wrote: <br/>&gt; http://sial.org/pbot/37077<br/>&gt; A slightly improved syntax, as per jnthn++ suggestion...<br/><br/>My list mail has been very delayed, so this may be out of sequence, but<br/>in case no one mentioned it yet:<br/><br/> http://sial.org/pbot/37102<br/><br/>(That&#39;s ruoso++&#39;s later 37100 paste with a couple small tweaks by me.)<br/><br/>I wanted to shrink that even further by replacing the given/when with a<br/>direct call of the correct op variant, but I couldn&#39;t figure out how to<br/>do that in current Rakudo. (And just using eval inside a multi seemed<br/>to be broken.)<br/><br/><br/>-&#39;f<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1111.html Mon, 08 Jun 2009 09:19:54 +0000 Re: RPN calculator in Perl 6 by Daniel Ruoso Em Dom, 2009-06-07 &agrave;s 00:07 +0200, Daniel Carrera escreveu:<br/>&gt; Daniel Ruoso wrote:<br/>&gt; &gt;&gt; Are you planning to write a post explaining how your program works?<br/>&gt; &gt; Maybe, but if you want to beat me to it, feel free ;)<br/>&gt; &gt;&gt; I figure that the explanation is as useful as the example. I sure<br/>&gt; &gt;&gt; spent a lot of time writing the blog post.<br/>&gt; &gt; I&#39;m not sure I&#39;ll have the time to write it soon, but it will certainly<br/>&gt; &gt; be on my list, unless you kindly post about it first ;)<br/>&gt; Honestly, I don&#39;t really know how your version works.<br/><br/>I&#39;ll take the code as in http://sial.org/pbot/37089<br/>Feel free to post it if you like...<br/><br/>Ok, I think I can skip the first part, where I declare a token Num,<br/>since your example explain it in great detail.<br/><br/>At first I&#39;m using multi subs, the declaration is just<br/><br/> multi name ($a, $b) {...}<br/><br/>and is just a shortcut for<br/><br/> our multi sub name ($a, $b) {...}<br/><br/>which means we&#39;re declaring a sub named &#39;&amp;name&#39; which will also be<br/>registered in the current package (our), with the signature inside the<br/>parens. This will work mostly as multis work in other languages, it will<br/>invoke the variant which signature matches the parameters.<br/><br/>The second point is the use of the &quot;infix:&lt;rpn&gt;&quot; name in the multi. This<br/>is how you declare new operators in Perl 6. infix describe the syntatic<br/>category of the operator, in this specific case, it means the operator<br/>stays between two values. So, after defining the multi sub, I could just<br/>use:<br/><br/> 5 rpn 4<br/><br/>and this would invoke<br/><br/> infix:&lt;rpn&gt;(5, 4)<br/><br/>If you&#39;re following until here, you probably realize that I could also<br/>do<br/><br/> ((5 rpn 4) rpn &#39;+&#39;) rpn 3<br/><br/>but Perl 6 has the &quot;reduce meta operator&quot;, which takes any infix<br/>operator and builds the above grouping for an arbitrary list, and that&#39;s<br/>the last line of the code<br/><br/> [rpn] @*ARGS[0].words;<br/><br/>This takes the list of words in @*ARGS[0] (which means I require a space<br/>between every token) and reduces it using the infix:&lt;rpn&gt; operator,<br/>which is implemented by each of the variants in the code.<br/><br/>The reduce meta-op works by taking the first two elements of the list<br/>and running the infix:&lt;rpn&gt; with them as parameters, take the result of<br/>that and the next element of the list and call it again, then do it<br/>again until the list ends.<br/><br/>The last thing you need to know to understand this is about subsets, as<br/>used in the signature of most variants<br/><br/> multi infix:&lt;rpn&gt; ($a where /&lt;Num&gt;/, $b where /&lt;Num&gt;/) {...}<br/><br/>This signature will take two arguments where both must match the Num<br/>token. This happens to be the variant that matches the start of the<br/>list, and it is the only one that doesn&#39;t expect an Array as the first<br/>argument, because it will itself return an Array with the two numbers.<br/>As the reduce metaop takes the result from this call and the next<br/>element on the list to call the sub again, the next call will receive an<br/>array with the two first numbers as the first argument and the next<br/>token as second argument, then the signature match does its trick and we<br/>go on until we reach the end of the list, and the last calculation is<br/>made.<br/><br/>This solution is mostly a functional solution. Probably if you ask the<br/>LISP guys to work on a program to do RPN, it will probably look like<br/>this...<br/><br/>daniel<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1110.html Mon, 08 Jun 2009 09:05:19 +0000 Re: RPN calculator in Perl 6 by Daniel Ruoso Em S&aacute;b, 2009-06-06 &agrave;s 19:45 -0400, Minimiscience escreveu:<br/>&gt; my $ls = @a.shift;<br/>&gt; my $rs = @a.shift;<br/>&gt; To:<br/>&gt; my $rs = @a.pop;<br/>&gt; my $ls = @a.pop;<br/><br/>Thanks... this was already solved in the latest version I sent<br/><br/>http://sial.org/pbot/37089<br/><br/>daniel<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1109.html Mon, 08 Jun 2009 09:05:18 +0000 Re: RPN calculator in Perl 6 by Daniel Ruoso http://sial.org/pbot/37077<br/>A slightly improved syntax, as per jnthn++ suggestion...<br/><br/>Em S&aacute;b, 2009-06-06 &agrave;s 18:08 +0200, Daniel Carrera escreveu:<br/>&gt; Daniel Carrera wrote<br/>&gt; &gt; Ok, try again:<br/>&gt; &gt; % perl6 rpn.pl &quot;2 2+&quot;<br/>&gt; &gt; 2 2<br/>&gt; You can probably fix that with a different split() line. I tried using <br/>&gt; &lt;ws&gt; instead of \s+ but the program just hangs forever.<br/><br/>Hmm.. it certainly is in the split, I&#39;m not sure how to get the barrier<br/>between the 2 and the +....<br/><br/>&gt; I also tried a more complex expression, and the calculator didn&#39;t like it:<br/>&gt; % perl6 rpn.pl &quot;5 4 + 3 / 5 3 - *&quot;<br/>&gt; Error parsing expression near *<br/><br/>er... that&#39;s because I didn&#39;t tried to implement it... but it certainly<br/>is possible to, just by declaring the :(@a, Num $a) variant...<br/><br/>daniel<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1108.html Mon, 08 Jun 2009 08:56:56 +0000 Re: How to speed up a grammar by Leon Timmermans On Sun, Jun 7, 2009 at 1:44 AM, Minimiscience&lt;minimiscience@gmail.com&gt; wrote:<br/>&gt;<br/>&gt; This is just a wild, uneducated, possibly delusional guess, but I don&#39;t<br/>&gt; think that vertical bar before the &#39;/&gt;&#39; should be there. &nbsp;I think it might<br/>&gt; be causing the grammar engine to check whether it can omit the ending of<br/>&gt; each tag and attach it to the enclosing tag instead, which it can&#39;t confirm<br/>&gt; without examining the whole file at least once for each tag.<br/>&gt;<br/><br/>In Perl 5 regexps that would be a problem, but in Perl 6 it shouldn&#39;t<br/>AFAIK. See &quot;Nothing is illegal&quot; in S05.<br/><br/>Leon<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1107.html Sun, 07 Jun 2009 10:46:13 +0000 Re: RPN calculator in Perl 6 by Minimiscience [I just realized I sent this directly to Daniel rather than to the <br/>list, so for the benefit of onlookers...]<br/><br/>On Jun 6, 2009, at 1:51 PM, Daniel Carrera wrote:<br/>&gt; Daniel Ruoso wrote:<br/>&gt;&gt; Yes... that&#39;s what wasn&#39;t implemented... But now it is ;)<br/>&gt;&gt; http://sial.org/pbot/37085<br/>&gt;<br/>&gt; Close, but...<br/>&gt;<br/>&gt; % perl6 rpn.pl &quot;5 4 + 3 / 5 3 - *&quot;<br/>&gt; -6<br/>&gt;<br/>&gt; That should be a positive 6.<br/><br/>I think I see the problem (assuming it hasn&#39;t already been pointed out <br/>off-list). The infix:&lt;rpn&gt;(@a, $op where ...) operators call .shift <br/>on the arrays to get the operands, yet the infix:&lt;rpn&gt;(... , $b where / <br/>&lt;Num&gt;/) operators place the numbers on the *end* of the stack, where <br/>the next reverse-polish operator should read them from. Thus, when <br/>the &#39;-&#39; is processed, the stack is &quot;3 5 3&quot;, where the first three is <br/>the result of &quot;5 4 + 3 /&quot;, and the first two numbers are shifted off <br/>for subtraction rather than the last two. In order to fix this, <br/>either change the first two infix:&lt;rpn&gt;() functions so that they place <br/>new numbers at the *beginning* of the array, or else change each <br/>occurrence of<br/><br/> my $ls = @a.shift;<br/> my $rs = @a.shift;<br/><br/>To:<br/><br/> my $rs = @a.pop;<br/> my $ls = @a.pop;<br/><br/>(Note that, in addition to the use of .pop, $rs is now acquired before <br/>$ls.)<br/><br/>At least, I think that&#39;s how it works.<br/><br/>-- Minimiscience<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1106.html Sat, 06 Jun 2009 16:46:08 +0000 Re: How to speed up a grammar by Minimiscience On Jun 6, 2009, at 10:32 AM, Richard Hainsworth wrote:<br/>&gt; rule element {<br/>&gt; &#39;&lt;&#39; &lt;name&gt; &lt;attribute&gt;*<br/>&gt; [<br/>&gt; | &#39;/&gt;&#39;<br/>&gt; | &#39;&gt;&#39; &lt;element&gt;* &#39;&lt;/&#39; $&lt;name&gt; &#39;&gt;&#39;<br/>&gt; ]<br/>&gt; }<br/><br/>This is just a wild, uneducated, possibly delusional guess, but I <br/>don&#39;t think that vertical bar before the &#39;/&gt;&#39; should be there. I <br/>think it might be causing the grammar engine to check whether it can <br/>omit the ending of each tag and attach it to the enclosing tag <br/>instead, which it can&#39;t confirm without examining the whole file at <br/>least once for each tag.<br/><br/>-- Minimiscience<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1105.html Sat, 06 Jun 2009 16:44:27 +0000 Re: RPN calculator in Perl 6 by Daniel Carrera Daniel Ruoso wrote:<br/>&gt;&gt; Are you planning to write a post explaining how your program works?<br/>&gt; <br/>&gt; Maybe, but if you want to beat me to it, feel free ;)<br/>&gt; <br/>&gt;&gt; I figure that the explanation is as useful as the example. I sure<br/>&gt;&gt; spent a lot of time writing the blog post.<br/>&gt; <br/>&gt; I&#39;m not sure I&#39;ll have the time to write it soon, but it will certainly<br/>&gt; be on my list, unless you kindly post about it first ;)<br/><br/>Honestly, I don&#39;t really know how your version works.<br/><br/>Daniel.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1104.html Sat, 06 Jun 2009 15:08:00 +0000 Re: RPN calculator in Perl 6 by Daniel Carrera Daniel Ruoso wrote:<br/>&gt; Yes... that&#39;s what wasn&#39;t implemented... But now it is ;)<br/>&gt; <br/>&gt; http://sial.org/pbot/37085<br/><br/>Close, but...<br/><br/>% perl6 rpn.pl &quot;5 4 + 3 / 5 3 - *&quot;<br/>-6<br/><br/><br/>That should be a positive 6.<br/><br/>Are you planning to write a post explaining how your program works? I <br/>figure that the explanation is as useful as the example. I sure spent a <br/>lot of time writing the blog post.<br/><br/>Cheers,<br/>Daniel.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1103.html Sat, 06 Jun 2009 10:51:48 +0000 Re: RPN calculator in Perl 6 by Daniel Carrera Daniel Ruoso wrote:<br/>&gt;&gt; You can probably fix that with a different split() line. I tried using <br/>&gt;&gt; &lt;ws&gt; instead of \s+ but the program just hangs forever.<br/>&gt; <br/>&gt; Hmm.. it certainly is in the split, I&#39;m not sure how to get the barrier<br/>&gt; between the 2 and the +....<br/><br/>Does Perl 6 still have the word barrier \b regex? Maybe some sort of <br/>character class that matches spaces and word boundaries? I dunno...<br/><br/><br/>&gt;&gt; I also tried a more complex expression, and the calculator didn&#39;t like it:<br/>&gt;&gt; % perl6 rpn.pl &quot;5 4 + 3 / 5 3 - *&quot;<br/>&gt;&gt; Error parsing expression near *<br/>&gt; <br/>&gt; er... that&#39;s because I didn&#39;t tried to implement it... but it certainly<br/>&gt; is possible to, just by declaring the :(@a, Num $a) variant...<br/><br/>Well, * is implemented, so I guess you are talking about complex <br/>expressions.<br/><br/>Daniel.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1102.html Sat, 06 Jun 2009 09:23:06 +0000 Re: RPN calculator in Perl 6 by Daniel Carrera Daniel Carrera wrote<br/>&gt; Ok, try again:<br/>&gt; <br/>&gt; % perl6 rpn.pl &quot;2 2+&quot;<br/>&gt; 2 2<br/><br/>You can probably fix that with a different split() line. I tried using <br/>&lt;ws&gt; instead of \s+ but the program just hangs forever.<br/><br/>I also tried a more complex expression, and the calculator didn&#39;t like it:<br/><br/>% perl6 rpn.pl &quot;5 4 + 3 / 5 3 - *&quot;<br/>Error parsing expression near *<br/><br/>:-(<br/><br/>Daniel.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1101.html Sat, 06 Jun 2009 09:08:24 +0000 Re: RPN calculator in Perl 6 by Daniel Carrera Daniel Carrera wrote:<br/>&gt;&gt; http://sial.org/pbot/37075<br/>&gt; <br/>&gt; % perl rpn.pl &quot;2 2 +&quot;<br/><br/>Tee hee... that should have been &quot;perl6&quot;. :-)<br/><br/>Ok, try again:<br/><br/>% perl6 rpn.pl &quot;2 2+&quot;<br/>2 2<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1100.html Sat, 06 Jun 2009 09:00:36 +0000 Re: RPN calculator in Perl 6 by Daniel Carrera Daniel Ruoso wrote:<br/>&gt; TIMTOWTDI ;)<br/><br/>The objective of the blog was more about the learning + teaching <br/>experience than anything else.<br/><br/><br/>&gt; http://sial.org/pbot/37075<br/><br/><br/> % perl rpn.pl &quot;2 2 +&quot;<br/>Semicolon seems to be missing at rpn.pl line 2.<br/>String found where operator expected at rpn.pl line 13, near &quot;where &#39;+&#39;&quot;<br/> (Do you need to predeclare where?)<br/>Array found where operator expected at rpn.pl line 14, near &quot;] &quot;<br/> (Missing operator before ?)<br/>Scalar found where operator expected at rpn.pl line 14, near &quot;@($a&quot;<br/> (Missing operator before $a?)<br/>String found where operator expected at rpn.pl line 17, near &quot;where &#39;-&#39;&quot;<br/> (Do you need to predeclare where?)<br/>Array found where operator expected at rpn.pl line 18, near &quot;] &quot;<br/> (Missing operator before ?)<br/>Scalar found where operator expected at rpn.pl line 18, near &quot;@($a&quot;<br/> (Missing operator before $a?)<br/>String found where operator expected at rpn.pl line 21, near &quot;where &#39;*&#39;&quot;<br/> (Do you need to predeclare where?)<br/>Array found where operator expected at rpn.pl line 22, near &quot;*] &quot;<br/> (Missing operator before ?)<br/>Scalar found where operator expected at rpn.pl line 22, near &quot;@($a&quot;<br/> (Missing operator before $a?)<br/>Semicolon seems to be missing at rpn.pl line 24.<br/>String found where operator expected at rpn.pl line 25, near &quot;where &#39;/&#39;&quot;<br/> (Do you need to predeclare where?)<br/>Semicolon seems to be missing at rpn.pl line 28.<br/>String found where operator expected at rpn.pl line 30, near &quot;fail <br/>&#39;Error parsing expression near &#39;&quot;<br/> (Do you need to predeclare fail?)<br/>Array found where operator expected at rpn.pl line 33, near &quot;] &quot;<br/> (Missing operator before ?)<br/>Bareword found where operator expected at rpn.pl line 33, near &quot;@*ARGS&quot;<br/> (Missing operator before ARGS?)<br/>Operator or semicolon missing before *ARGS at rpn.pl line 33.<br/>Ambiguous use of * resolved as operator * at rpn.pl line 33.<br/>syntax error at rpn.pl line 1, near &quot;\.&quot;<br/>Missing right curly or square bracket at rpn.pl line 34, at end of line<br/>Execution of rpn.pl aborted due to compilation errors.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1099.html Sat, 06 Jun 2009 08:58:05 +0000 How to speed up a grammar by Richard Hainsworth Leon Timmermans wrote:<br/>&gt; If you want to write a fast parser for XML, preventing backtracking is<br/>&gt; going to be quite essential. I suspect the problem is your grammar,<br/>&gt; not the grammar engine itself. You could post it to perl6-users and<br/>&gt; ask for advice on it.<br/>&gt;<br/>&gt; Leon<br/><br/>Below is the grammar.<br/><br/>I am only interested in tag names &lt;xs1:text&gt; &lt;xs1:playlist&gt; (and within <br/>playlist) &lt;xs1:item&gt;<br/>The only attributes I want are &#39;author&#39;, &#39;title&#39;, and &#39;id&#39;<br/><br/>grammar sony_grammar;<br/>rule TOP {<br/> ^<br/> &lt;xmldecl&gt;?<br/> &lt;root=element&gt;<br/> $<br/>}<br/><br/>rule xmldecl {<br/> &#39;&lt;?xml&#39;<br/> &#39;version&#39; &#39;=&#39; &#39;&quot;&#39; $&lt;version&gt;=&lt;-[\&quot;]&gt;+ &#39;&quot;&#39;<br/> &#39;encoding&#39; &#39;=&#39; &#39;&quot;&#39; $&lt;encoding&gt;=&lt;-[\&quot;]&gt;+ &#39;&quot;&#39;<br/> &#39;?&gt;&#39;<br/>}<br/><br/>rule element {<br/> &#39;&lt;&#39; &lt;name&gt; &lt;attribute&gt;*<br/> [<br/> | &#39;/&gt;&#39;<br/> | &#39;&gt;&#39; &lt;element&gt;* &#39;&lt;/&#39; $&lt;name&gt; &#39;&gt;&#39;<br/> ]<br/>}<br/><br/>rule attribute { &lt;name&gt; &#39;=&#39; &#39;&quot;&#39; $&lt;value&gt;=&lt;-[&quot;]&gt;* &#39;&quot;&#39; }<br/><br/>token name { &lt;namespace&gt;? $&lt;ename&gt;=&lt;ident&gt; }<br/>token namespace { &lt;ident&gt; &#39;:&#39; }<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1098.html Sat, 06 Jun 2009 07:33:11 +0000 RPN calculator in Perl 6 by Daniel Carrera Hi all,<br/><br/>I just wrote a blog post showing how to make a reverse polish notation <br/>calculator in Perl 6. In the process I show some of Perl 6&#39;s grammar <br/>features.<br/><br/>Someone in IRC thought it was good, so I decided to post here in the off <br/>chance that someone else finds it interesting or useful.<br/><br/>http://daniel.carrera.bz/2009/06/rpn-calculator-in-perl-6/<br/><br/>Cheers,<br/>Daniel.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1097.html Sat, 06 Jun 2009 05:06:32 +0000 Re: the file slurping is not working by Tom Christiansen Larry wrote:<br/><br/>&raquo; Indeed, that preference is why Perl 6 can (we hope) get away with<br/>&raquo; autochomping, where Perl 5 can&#39;t (as easily). Or more accurately,<br/>&raquo; we choose not to special-case &quot;while (&lt;&gt;)&quot; as Perl 5 does (because<br/>&raquo; even Perl 5 has difficulties with files that are accidentally<br/>&raquo; &quot;autochomped&quot; by omitting the final newline in the file).<br/><br/>I don&#39;t understand what you mean, Larry.<br/><br/>Sure, Perl *4* had such difficulties, since having only <br/>chop(), not an RS-aware chomp(), you&#39;d get a:<br/><br/> substr($line,-1) = q() <br/><br/>whether you &quot;needed&quot; it or not (although it returns the old LHS not the <br/>new RHS). It&#39;s not conditional, except that it won&#39;t give you negatively<br/>lengthed null lines. And so those folks who deemed textfiles as<br/>\n-SEPARATED sequences of lines, not \n-TERMINATED sequences, would<br/>therefore shorten their files by a character if they didn&#39;t check first.<br/><br/>But with Perl *5*, since chomp() is RS-aware in that it instead <br/>looks for it leaps--er, checks before it chomps--so I&#39;m don&#39;t <br/>at all understand what you mean when you say<br/><br/>&raquo; even Perl 5 has difficulties with files that are accidentally<br/>&raquo; &quot;autochomped&quot; by omitting the final newline in the file).<br/><br/>I don&#39;t see where you see Perl 5 having that problem. This <br/>seems safe enough, which to a first approximation about this:<br/><br/> $line =~ s[ ${RS} \z ][]x;<br/><br/>Even when $RS = q!!, making for squishy record terminators<br/>for both readline() and also for chomp(), I see no destructive <br/>action. Often enough I set $RS = &quot;%%\n&quot;, and sometimes I remember<br/>to put a %% at the end, and sometimes I don&#39;t, but no harm done.<br/><br/>The only place I can see there being a &quot;problem&quot; is with <br/>something like <br/><br/> % perl -i&#39;IBACKUP/*&#39; lpe &#39;s/foo/bar/g&#39; file*<br/><br/>and some of those files start out without their terminator.<br/><br/>Here though the problem is opposite what you mention, in <br/>that once Perl&#39;s had its way with them, all files are <br/>canonically terminated whether they began that way or not.<br/><br/>&raquo; But we&#39;re trying very hard to get rid of most such special<br/>&raquo; cases in Perl 6. Usually we can get the recommended Perl<br/>&raquo; 6 code to just DWYM as a fallout of the general semantics,<br/>&raquo; but in this particular case, if you really want to read<br/>&raquo; your input with while, there&#39;s a slight &quot;regression&quot; from<br/>&raquo; Perl 5 insofar as you must explicitly use defined(). This<br/>&raquo; de-huffmanization is intended as a subtle encouragement to<br/>&raquo; move from Item-Think towards List-Think. :)<br/><br/>Oh. <br/><br/>You mean like for directories containing a file whose <br/>name is the 1-char string, &quot;0&quot;, and that file pre-emptively<br/>terminating a readdir loop the way it used to. <br/><br/>Whereas nowadays, our compassionate compiler, spotting an<br/>incorrectly tested assignment governing a while&#39;s conditional:<br/><br/> while ( $thingie = &lt;read{dir,lin[ke]}&gt;() ) { ;;; } <br/><br/>graciously inserts a defined() opcode for you.<br/><br/>Wasn&#39;t the reasoning that whenever there&#39;s something each and every<br/>program must without fail do if it&#39;s to be a correct program, that<br/>something is too important to be left up to the programmer to forget?<br/><br/>Is this rationale no longer sound? <br/><br/>It still makes sense to me.<br/><br/>Then again, folks can still confuse interating using a while with <br/>iterating using foreach. They often appear act the same, so <br/>the wrong mental model is held. People <br/>grow complacent, having seen the misleading apparent interchangeability<br/>between<br/><br/> while ( $src = &lt;*.[Cchy]&gt; ) { }<br/> foreach $src ( &lt;*.[Cchy]&gt; ) { }<br/><br/>or<br/><br/> while ( $datum = &lt;$yafh&gt; ) { }<br/> foreach $datum ( &lt;$yafh&gt; ) { }<br/><br/>They then get quite hung up when these aren&#39;t the same:<br/><br/> foreach $item (@someitems) { ;;; }<br/> while ( $item = shift(@someitems) ) { ;;; } <br/><br/>I guess removing special awareness for &lt;read{dir,lin[ke]}&gt; might<br/>prod them into thinking more about the whole thing. After all,<br/>no special blessing of an inserted defined() op can save them<br/>here, condering that this:<br/><br/> while ( defined( $item = shift(@someitems) ) ) { ;;; } <br/><br/>still isn&#39;t the same as this:<br/><br/> while (@someitems) { <br/> $item = shift(@someitems);<br/> ;;;<br/> }<br/><br/>Still, whenever there&#39;s something everyone has to do for a program<br/>to function correctly, shouldn&#39;t Perl be doing it for them whenever<br/>possible, lest they sometimes forget? Think of the Python programs<br/>that die because they forget to pre-extend their lists to grow it<br/>by one. Perl after all never makes you write:<br/><br/> if ($#someitems &lt; $index) {<br/> $#someitems = $index;<br/> } <br/> $sometimes[$index] = $value;<br/><br/>EACH AND EVERY $@%&amp;* time you want to write<br/><br/> $sometimes[$index] = $value;<br/><br/>but Python does. <br/><br/>But perhaps this is something for the &lt;ITERATOR&gt; to <br/>see to tkaing care of, or the I/O aka line-discipline, <br/>or whatever model you prefer.<br/><br/>--tom<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1096.html Sat, 06 Jun 2009 04:39:46 +0000 Re: the file slurping is not working by Larry Wall On Fri, Jun 05, 2009 at 01:39:02PM +0200, Carl M&auml;sak wrote:<br/>: Daniel (&gt;), Leon (&gt;&gt;), Daniel (&gt;&gt;&gt;):<br/>: &gt;&gt;&gt; Then why is it that .get works fine for $*IN?<br/>: &gt;&gt;&gt;<br/>: &gt;&gt;&gt; while $*IN.get -&gt; $line {<br/>: &gt;&gt;&gt; &nbsp; &nbsp; &nbsp; say $line<br/>: &gt;&gt;&gt; }<br/>: &gt;&gt;&gt;<br/>: &gt;&gt;<br/>: &gt;&gt; Because you&#39;re using a while loop instead of a for loop ;-)<br/>: &gt;<br/>: &gt; Worse. The code I wrote has a subtle but horrible error. The condition will<br/>: &gt; fail as soon as you hit a blank line!!<br/>: <br/>: Which, I think, summarizes why the &#39;for $*IN.lines&#39; idiom is preferred<br/>: in Perl 6.<br/><br/>Indeed, that preference is why Perl 6 can (we hope) get away with<br/>autochomping, where Perl 5 can&#39;t (as easily). Or more accurately,<br/>we choose not to special-case &quot;while (&lt;&gt;)&quot; as Perl 5 does (because<br/>even Perl 5 has difficulties with files that are accidentally<br/>&quot;autochomped&quot; by omitting the final newline in the file).<br/><br/>But we&#39;re trying very hard to get rid of most such special cases in<br/>Perl 6. Usually we can get the recommended Perl 6 code to just DWYM<br/>as a fallout of the general semantics, but in this particular case,<br/>if you really want to read your input with while, there&#39;s a slight<br/>&quot;regression&quot; from Perl 5 insofar as you must explicitly use defined().<br/>This de-huffmanization is intended as a subtle encouragement to move<br/>from Item-Think towards List-Think. :)<br/><br/>Larry<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1095.html Fri, 05 Jun 2009 11:32:24 +0000 Re: the file slurping is not working by Carl Mäsak Daniel (&gt;), Leon (&gt;&gt;), Daniel (&gt;&gt;&gt;):<br/>&gt;&gt;&gt; Then why is it that .get works fine for $*IN?<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; while $*IN.get -&gt; $line {<br/>&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; say $line<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; Because you&#39;re using a while loop instead of a for loop ;-)<br/>&gt;<br/>&gt; Worse. The code I wrote has a subtle but horrible error. The condition will<br/>&gt; fail as soon as you hit a blank line!!<br/><br/>Which, I think, summarizes why the &#39;for $*IN.lines&#39; idiom is preferred<br/>in Perl 6.<br/><br/>// Carl<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1094.html Fri, 05 Jun 2009 04:39:15 +0000 Re: the file slurping is not working by Daniel Carrera Leon Timmermans wrote:<br/>&gt;&gt; Then why is it that .get works fine for $*IN?<br/>&gt;&gt;<br/>&gt;&gt; while $*IN.get -&gt; $line {<br/>&gt;&gt; say $line<br/>&gt;&gt; }<br/>&gt;&gt;<br/>&gt; <br/>&gt; Because you&#39;re using a while loop instead of a for loop ;-)<br/><br/>Worse. The code I wrote has a subtle but horrible error. The condition <br/>will fail as soon as you hit a blank line!!<br/><br/>Daniel.<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1093.html Fri, 05 Jun 2009 03:58:00 +0000 Re: rakudo-current loop 2-3 orders of magnitude slower than perl 5? by Steffen Schwigon Parrot Raiser &lt;1parrota@gmail.com&gt; writes:<br/>&gt; If Sun&#39;s propaganda about Dtrace :<br/>&gt; http://www.sun.com/bigadmin/content/dtrace/ is anywhere near true<br/><br/>Which I can confirm. DTrace *is* cool.<br/><br/>Steffen<br/>-- <br/>Steffen Schwigon &lt;ss5@renormalist.net&gt;<br/>Dresden Perl Mongers &lt;http://dresden-pm.org/&gt;<br/>Deutscher Perl-Workshop &lt;http://www.perl-workshop.de/&gt;<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1092.html Fri, 05 Jun 2009 03:46:23 +0000 Re: the file slurping is not working by Leon Timmermans &gt;<br/>&gt; Then why is it that .get works fine for $*IN?<br/>&gt;<br/>&gt; while $*IN.get -&gt; $line {<br/>&gt; &nbsp; &nbsp; &nbsp; &nbsp;say $line<br/>&gt; }<br/>&gt;<br/><br/>Because you&#39;re using a while loop instead of a for loop ;-)<br/><br/>Leon<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1091.html Fri, 05 Jun 2009 03:42:37 +0000 Re: the file slurping is not working by Daniel Carrera Carl M&auml;sak wrote:<br/>&gt; Aruna (&gt;):<br/>&gt;&gt; I tested the below code on parrot-1.1.0 and it read all the lines in the<br/>&gt;&gt; file and tested same code on the latest git update (4th June 2009), it<br/>&gt;&gt; outputs only the first line.<br/>&gt; <br/>&gt; That&#39;s what C&lt;$file.get&gt; does -- it gives you one line per default.<br/>&gt; You want C&lt;$file.lines&gt;.<br/><br/>Then why is it that .get works fine for $*IN?<br/><br/>while $*IN.get -&gt; $line {<br/> say $line<br/>}<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1090.html Fri, 05 Jun 2009 03:17:37 +0000 Re: the file slurping is not working by Aruna Goke Carl M&auml;sak wrote:<br/>&gt; Aruna (&gt;):<br/>&gt;&gt; I tested the below code on parrot-1.1.0 and it read all the lines in the<br/>&gt;&gt; file and tested same code on the latest git update (4th June 2009), it<br/>&gt;&gt; outputs only the first line.<br/>&gt; <br/>&gt; That&#39;s what C&lt;$file.get&gt; does -- it gives you one line per default.<br/>&gt; You want C&lt;$file.lines&gt;.<br/>&gt; <br/>&gt; // Carl<br/>&gt; <br/>Thanks.<br/><br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1089.html Fri, 05 Jun 2009 03:14:55 +0000 Re: the file slurping is not working by Carl Mäsak Aruna (&gt;):<br/>&gt; I tested the below code on parrot-1.1.0 and it read all the lines in the<br/>&gt; file and tested same code on the latest git update (4th June 2009), it<br/>&gt; outputs only the first line.<br/><br/>That&#39;s what C&lt;$file.get&gt; does -- it gives you one line per default.<br/>You want C&lt;$file.lines&gt;.<br/><br/>// Carl<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1088.html Fri, 05 Jun 2009 03:08:38 +0000 Announcing pun (Re: rakudo-current loop 2-3 orders of magnitude slower than perl 5?) by Carl Mäsak Steffen (&gt;), Fagyal (&gt;&gt;):<br/>&gt;&gt; However, performance is an issue. I would not mind running into<br/>&gt;&gt; bugs, writing some extra code to work around missing stuff, etc.,<br/>&gt;&gt; but right now it is just hard to find any projects (for me - YMMV)<br/>&gt;&gt; where performance would not be a blocker.<br/>&gt;<br/>&gt; I suggest to start using it as replacement for sysadmin automation<br/>&gt; tasks. The same way Perl started to replace sh/sed/awk. This would not<br/>&gt; need all the funky OO or FP features you get with Perl 6 but many of<br/>&gt; those tasks are not speed critical and still of practical use and<br/>&gt; would already benefit from the syntax cleanup compared to Perl 5.<br/><br/>I&#39;ll take this opportunity to announce &#39;pun&#39;, a small Perl 6 project<br/>to emulate the behaviour of the -p and -n flags in Rakudo. (The name<br/>&#39;pun&#39;, believe it or not, doesn&#39;t stand for anything in particular.)<br/><br/>pun<br/> &lt;http://github.com/masak/pun/&gt;<br/><br/>The principle behind it is easy: you just type &#39;perl6n&#39; instead of<br/>&#39;perl6 -n&#39;. Same thing for &#39;perl6p&#39; and &#39;perl6 -p&#39;.<br/><br/>$ ./perl6p -e .=flip # here&#39;s a rev clone<br/>I CAN HAZ BACKWARDS?<br/>?SDRAWKCAB ZAH NAC I<br/>^D<br/><br/>I find this is an excellent way to start using Perl 6 for simple<br/>sed/awk-like tasks today. Maybe some of you will too.<br/><br/>If you try pun and would like to comment, critique, patch, document,<br/>or otherwise improve the software for the greater good of the Perl 6<br/>community, please don&#39;t hesitate to contact me, via email or #perl6 on<br/>freenode.<br/><br/>// Carl<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1087.html Fri, 05 Jun 2009 03:02:47 +0000 the file slurping is not working by Aruna Goke I tested the below code on parrot-1.1.0 and it read all the lines in the <br/>file and tested same code on the latest git update (4th June 2009), it <br/>outputs only the first line.<br/><br/>#!/usr/bin/perl6<br/><br/>use v6;<br/><br/>my $fname = &#39;README&#39;;<br/><br/>if my $file = open($fname, :r) {<br/>for $file.get-&gt; $line {<br/>say $line;<br/> }<br/> } else {<br/> say &quot;could not open $fname bcos : $!&quot;;<br/>}<br/>close($file);<br/><br/>what is happening?<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1086.html Fri, 05 Jun 2009 02:58:49 +0000 Re: rakudo-current loop 2-3 orders of magnitude slower than perl 5? by Parrot Raiser If Sun&#39;s propaganda about Dtrace :<br/>http://www.sun.com/bigadmin/content/dtrace/ is anywhere near true, it<br/>sounds as though it&#39;s a wheel we won&#39;t have to invent for<br/>Parrot/Rakudo. It is apparently also available for Mac OS (Leopard)<br/>http://tinyurl.com/2xas7q<br/> http://www.nntp.perl.org/group/perl.perl6.users/2009/06/msg1085.html Fri, 05 Jun 2009 02:26:27 +0000