fglock's Journal http://use.perl.org/~fglock/journal/ fglock's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:23:22+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 fglock's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~fglock/journal/ Fun with "go routines" in Perl 6 http://use.perl.org/~fglock/journal/40310?from=rss <p>I've just added experimental support to "go routines" to Perlito's Go backend:</p><p>$ perl mp6.pl -Bgo -e ' go sub { say 123; say "aaa" }; go sub { say 456; say "bbb" }; say "here"; say "now"; '</p><p>here123456</p><p>nowaaabbb</p><p>Go "Channels" are not supported yet.</p> fglock 2010-04-12T19:32:05+00:00 journal "Perlito" MiniPerl6 4.0 - string-eval, more bootstraps http://use.perl.org/~fglock/journal/40255?from=rss Perlito is a subset of Perl 6, which was designed as a light bootstrapping language. <p>Changelog for version 4.0: </p><p>- Go backend bootstrap. </p><p> The Go backend was updated to the latest Go language spec. </p><p>- Perl5 backend optimized; 30% faster </p><p>- More library functions, added to all backends </p><p>- New 'Eval.pm' module - implements a MiniPerl6 interpreter in MiniPerl6. </p><p> This should add some debugging capabilities later on. </p><p>- New test suite. See README on how to use 'prove' for each backend. </p><p>- New compiler options to create binary executables </p><p>- Currently the stable backends are: Perl5, Javascript, JVM, Lisp, Go. </p><p> See README for bootstrapping instructions for all backends. </p><p>- Removed support for features that are not standard Perl6. </p><p>Thanks to pmurias++ for helping test this release. </p><p>Version 4.0 can be downloaded from </p><p> <a href="http://github.com/fglock/Perlito/tree/7f0ac392dfcf04d390ebefe5f4274bb37cbd7b6e">http://github.com/fglock/Perlito/tree/7f0ac392dfcf04d390ebefe5f4274bb37cbd7b6e</a> </p><p>Enjoy! </p><p>- Fl&#225;vio S. Glock (fglock)</p> fglock 2010-03-20T09:38:22+00:00 perl6 MiniPerl6 3.0 "Perlito" - Go lang, JVM backends http://use.perl.org/~fglock/journal/40117?from=rss <p> MiniPerl6 (mp6) is a subset of Perl 6, which was designed as a light bootstrapping language. </p><p> Changelog for version 3.0: </p><p> - Go language backend; using Go: <a href="http://golang.org/">http://golang.org/</a> </p><p> - Java-class backend; using Rhino: <a href="http://www.mozilla.org/rhino">http://www.mozilla.org/rhino</a> </p><p> - util/mp6.pl - compiler command line script written in MiniPerl6 </p><p> - new repository at <a href="http://github.com/fglock/Perlito">http://github.com/fglock/Perlito</a> </p><p> - new web page at <a href="http://www.perlito.org/">http://www.perlito.org/</a> created by nferraz (Nelson Ferraz) </p><p>Enjoy! </p><p> - Fl&#225;vio S. Glock (fglock)</p> fglock 2010-01-21T15:11:42+00:00 perl6 MiniPerl6 "Perlito" to Go language http://use.perl.org/~fglock/journal/39971?from=rss <p>I've been working on the "Go language" backend for Perlito miniperl6 for about 2 weeks now.</p><p>Yesterday I implemented functions and namespaces, and today I've got methods working. With some more work, Perlito should bootstrap in Go.</p><p>There is no command line script yet - I'm using this ugly line for tests (this compiles and runs the method tests):</p><p>$ perl mp6-go.pl &lt; t/11-bind-method-param.t &gt; x1.go &amp;&amp; cat lib/MiniPerl6/Go/Runtime.go x1.go &gt; x.go &amp;&amp; time ( rm x.6 ; rm<nobr> <wbr></nobr>./6.out ; 6g x.go ; 6l x.6 ;<nobr> <wbr></nobr>./6.out )</p><p>New urls:</p><p>Perlito now has a site http://www.perlito.org, created and maintained by Nelson Ferraz (NFERRAZ).</p><p>Yesterday I created a github account. The new Perlito commits are now going to http://github.com/fglock/Perlito</p> fglock 2009-12-03T21:23:15+00:00 perl6 "Perlito" MiniPerl6 runs in the browser http://use.perl.org/~fglock/journal/39664?from=rss <a href="http://perlcabal.org/~fglock/perlito.html">http://perlcabal.org/~fglock/perlito.html</a> <p>Press the "Execute" button!</p><p>"Perlito" MiniPerl6 is an implementation of a small subset of Perl6. There is no error handling, and the web interface I wrote is very simple.</p><p>The compiler implements simple classes, grammars with 'token' only, variable binding with ':=' (no assignment), arrays, hashes, strings, integers.</p><p>The compiler is entirely written in MiniPerl6. The source code is in:</p><p> <a href="http://svn.pugscode.org/pugs/v6/v6-MiniPerl6/lib/MiniPerl6/">http://svn.pugscode.org/pugs/v6/v6-MiniPerl6/lib/MiniPerl6/</a></p> fglock 2009-09-22T20:52:36+00:00 perl6 Playing with V8 parser http://use.perl.org/~fglock/journal/39617?from=rss <p>I've downloaded V8 (the javascript compiler). I was planning to try it out as a MiniPerl6 backend, but I started to play with the parser instead:</p><p> &nbsp; --- src/scanner.cc (revision 2877)<br> &nbsp; +++ src/scanner.cc (working copy)<br> &nbsp; @@ -858,6 +858,12 @@<br> &nbsp; &nbsp; &nbsp; bool has_escapes = false;</p><p> &nbsp; &nbsp; &nbsp; StartLiteral();<br> &nbsp; +<br> &nbsp; + if (c0_ == '$') {<br> &nbsp; + AddChar(c0_);<br> &nbsp; + Advance();<br> &nbsp; + }</p><p>Now I can use perl style var names:</p><p> &nbsp; $<nobr> <wbr></nobr>./shell<br> &nbsp; V8 version 1.3.10<br> &nbsp; &gt; $my_var = "hello, World!"; print($my_var);<br> &nbsp; hello, World!</p><p>*update* - I've changed a few more things, and I've got some timings:</p><p> &nbsp; $ time<nobr> <wbr></nobr>./shell -e ' my $x = 0; for (my $i=1; $i &lt; 10000000; $i++) { $x++ }; print($x);'<br> &nbsp; 9999999</p><p> &nbsp; real 0m0.164s<br> &nbsp; user 0m0.152s<br> &nbsp; sys 0m0.008s</p><p> &nbsp; $ time perl -e ' my $x = 0; for (my $i=1; $i &lt; 10000000; $i++) { $x++ }; print($x);'<br> &nbsp; 9999999<br> &nbsp; real 0m1.123s<br> &nbsp; user 0m1.091s<br> &nbsp; sys 0m0.008s</p> fglock 2009-09-12T18:08:45+00:00 perl6 MiniPerl6 1.0 "Perlito" bootstrapped in SBCL Lisp http://use.perl.org/~fglock/journal/39549?from=rss <p>MiniPerl6 (mp6) was <a href="href">designed</a> as a light bootstrapping language. The initial bootstrap used <a href="href">v6.pm</a> and was then self-hosted in Perl 5. </p><p>MiniPerl6 is now self-hosted in SBCL Lisp. You can modify the source code and recompile without Perl 5. </p><p>MiniPerl6 can be downloaded from the Pugs repository: </p><p> <code> $ svn checkout http://svn.pugscode.org/pugs pugs $ cd pugs/v6/v6-MiniPerl6 </code> </p><p>You can create an executable binary using these commands: </p><p> <code> $ sh lisp-util/create-core-image.sh $ sbcl --load mp6-lisp-create-core-image.lisp $ chmod +x mp6-lisp $<nobr> <wbr></nobr>./mp6-lisp -e ' class Main { say "hello, World!" } '<nobr> <wbr></nobr>... lisp compiler warnings hello, World! </code> </p><p>The bootstrapping procedure for both "perl" and "lisp" backends can be tested with: </p><p> <code> $ sh perl5-util/bootstrap-perl5.sh $ sh lisp-util/bootstrap-lisp.sh<nobr> <wbr></nobr>... lisp compiler warnings </code></p> fglock 2009-08-28T19:57:32+00:00 journal v6.pm is back http://use.perl.org/~fglock/journal/37056?from=rss <a href="http://search.cpan.org/dist/v6/">v6.pm</a> now passes a little more than 6000 tests from the Perl 6 test suite.<br> <br> "v6" is a CPAN module that implements a Perl 6 compiler that runs in Perl 5.<br> <br>It is compiling and running nearly 10 tests per second:<br> <br> &nbsp; Files=145, Tests=6210, 562 wallclock secs ( 1.41 usr 0.67 sys + 402.53 cusr 93.57 csys = 498.18 CPU)<br> &nbsp; Result: PASS<br> <br>Precompiled tests are running at 50 tests per second (running "make file" a second time execute the precompiled tests):<br> <br> &nbsp; Files=145, Tests=6210, 124 wallclock secs ( 0.88 usr 0.57 sys + 80.20 cusr 14.04 csys = 95.69 CPU)<br> &nbsp; Result: PASS fglock 2008-07-30T13:01:13+00:00 perl6 "KindaPerl6" project roadmap http://use.perl.org/~fglock/journal/33425?from=rss <p>I finished the first version of the KindaPerl6 project roadmap, after a whole month of planning, prioritizing, and procrastination. </p><p> This version is a filtered out "main development track", extracted from the otherwise <a href="http://svn.pugscode.org/pugs/v6/docs/kp6-Notes.txt"> anarchistic development structure </a> (somebody called it "genetic programming"). </p><p> The goal of phases and milestones here is really just to break the project down into bite-sized pieces that regular hackers can get their heads around. </p><p> Specifically, the plan doesn't tell people what they should not to do. Small projects are much welcome. You might even get a <a href="http://use.perl.org/article.pl?sid=07/03/22/1542235"> Perl 6 Microgrant </a>. I'm told that the TPF really wants to give out a couple of kp6/mp6/6STD grants! </p><p> The roadmap as html - <a href="http://moritz.faui2k3.org/pugs_pod/kp6-roadmap">http://moritz.faui2k3.org/pugs_pod/kp6-roadmap </a> </p><p> The roadmap as pod - <a href="http://svn.pugscode.org/pugs/v6/docs/kp6-roadmap.pod">http://svn.pugscode.org/pugs/v6/docs/kp6-roadmap.pod</a> </p> fglock 2007-06-04T18:31:39+00:00 journal Project ideas http://use.perl.org/~fglock/journal/32518?from=rss <p>These are Perl 6 project ideas that I've been working on:</p><p>- Develop kp6-C (started)</p><p>- Develop kp6-Parrot, writing new PMCs as-needed</p><p>- Finish kp6 closure and coroutine implementation (perl5 backend)</p><p>- Implement a lazy Array PMC (is this SoC'able?); coordinate with particle++ work on generators</p><p>- Find out how to implement lazy Arrays for pugs; maybe learn some Haskell</p><p>- Fix Pugs::Compiler::Rule to current specifications</p><p>- Make v6.pm (or kp6?) use the Perl6-STD grammar</p><p>- Finish Pugs::Compiler::Rule p5-regex backend, using the new features implemented by dmq++</p><p>- Merge some of kp6 ideas to v6.pm; this would help making v6.pm feature-complete</p><p>- Help putter++ with pluggable v6.pm</p> fglock 2007-02-27T12:11:37+00:00 journal Pugs::Compiler::Rule and Pugs http://use.perl.org/~fglock/journal/30782?from=rss <p>audreyt is considering using Pugs::Compiler::Rule as an alternate Rules library for Pugs, in addition to PGE.</p><p>audreyt and PerlJam suggested porting Rules to PCRE, which would let us bootstrap anywhere we can find PCRE (php, python, java, etc).</p><p>an alternative would be to implement P::C::R in plain Perl6, which is straightforward (and mostly done - see http://svn.openfoundry.org/pugs/v6/v6.pm/lib/Pugs/Grammar/P6P6Rule.pm),<br>or even, to port P::C::R to C (libp6re would require that the callback handlers be rewritten in C instead of Hs/P6/P5).</p> fglock 2006-08-28T20:58:58+00:00 journal towards a Pure-Perl6 v6.pm http://use.perl.org/~fglock/journal/30742?from=rss <p>The v6.pm module Pugs::Grammar::Term has been ported to Perl6 and it successfully replaces the Perl5 version.</p><p><a href="http://svn.openfoundry.org/pugs/perl5/Pugs-Compiler-Perl6/lib/Pugs/Grammar/P6Term.pm">lib/Pugs/Grammar/P6Term.pm</a></p><p>The circularity is handled by a<nobr> <wbr></nobr><a href="http://svn.openfoundry.org/pugs/perl5/Pugs-Compiler-Perl6/lib/Pugs/Grammar/P6Term.pmc">.pmc file</a>, which will be distributed together with the Perl6 source code.</p> fglock 2006-08-24T19:00:46+00:00 journal Pugs::Runtime::Value is under way http://use.perl.org/~fglock/journal/30643?from=rss <p>Pugs::Runtime::Value is v6.pm version of Perl6::Value and Perl6::Container, which were used in the PIL-Run project.</p><p>Instead of Perl6::MetaModel, Pugs::Runtime::Value uses the Perl 6 object system through 'use v6' - Pugs::Runtime::Value is pure-p6, except for very low-level stuff. Circularity - Yay!</p><p>http://svn.openfoundry.org/pugs/perl5/Pugs-Runtime-Value/</p> fglock 2006-08-15T22:05:07+00:00 journal Pugs::Compiler::Rule refactoring http://use.perl.org/~fglock/journal/30333?from=rss <p>Pugs::Compiler::Rule has been branched in the svn repository in order to fix some architecture problems:</p><p>- the bootstrapped compiler and the user-side runtime will no longer be shared. This will make it easier to make changes in the user-side, without needing to redo the bootstrap.</p><p>- there will be a single Match class - currently<nobr> <wbr></nobr>:ratchet and non-ratchet rules create different match objects. The unification will fix the long due TODO of allowing calls between ratchet and non-ratchet rules.</p><p>Today Audrey also contributed a change in the Match class, allowing '$($/)' to return the result object - this syntax is the long form of '$/()'.</p> fglock 2006-07-19T05:17:05+00:00 journal v6.pm rules http://use.perl.org/~fglock/journal/30189?from=rss <p>v6.pm now has rule declarations. It still needs some additional work to process parameters, etc. Then v6 will be able to compile it's own grammar, and maybe it will be entirely rewritten in P6 (except for the runtime modules).</p><p>Unfortunately, the build is currently broken in windows and osx - at least for unexperienced users, it seems. I'm planning to add eval() around the required binary modules, so that at least a subset of the language can work without XS compilation.</p> fglock 2006-07-06T04:06:25+00:00 journal my first v6.pm program to use a module in v6.pm! http://use.perl.org/~fglock/journal/30122?from=rss <p>I added the first OO test to v6.pm This is also the first v6.pm program to use a module written with v6.pm:</p><p> &nbsp; &nbsp; # file: t/10-moose1.t<br> &nbsp; &nbsp; use v6-pugs;</p><p> &nbsp; &nbsp; use lib './t', '.';<br> &nbsp; &nbsp; use moose1;</p><p> &nbsp; &nbsp; say '1..1';<br> &nbsp; &nbsp; say '1 ok # use Moose';</p><p>and the module:</p><p> &nbsp; &nbsp; # file: t/moose1.pm<br> &nbsp; &nbsp; use v6-pugs;<br> &nbsp; &nbsp; class Point;</p><p> &nbsp; &nbsp; has $.x is rw; # instance attributes<br> &nbsp; &nbsp; has $.y; # default "is readonly"&#8233;<br> &nbsp; &nbsp; method clear () {<br> &nbsp; &nbsp; &nbsp; &nbsp; $.x = 0; # accessible within the class<br> &nbsp; &nbsp; &nbsp; &nbsp; $.y = 0;<br> &nbsp; &nbsp; }</p><p>Very simple, isn't it? The second file was copied from audreyt's slides in YAPC::NA.</p><p>The files compile to:</p><p> &nbsp; # generated file: t/10-moose1.tc<br> &nbsp; use Pugs::Runtime::Perl6;<br> &nbsp; use strict;<br> &nbsp; no warnings 'void';<br> &nbsp; use lib( './t', '.' );<br> &nbsp; use moose1();<br> &nbsp; print '', '1..1';<br> &nbsp; print "\n";<br> &nbsp; print '', '1 ok # use Moose';<br> &nbsp; print "\n";<br> &nbsp; 1;</p><p>and:</p><p> &nbsp; # generated file: t/moose1.pmc<br> &nbsp; #<br> &nbsp; # [... checksum header removed<nobr> <wbr></nobr>...]<br> &nbsp; #<br> &nbsp; use Pugs::Runtime::Perl6;<br> &nbsp; use strict;<br> &nbsp; no warnings 'void';</p><p> &nbsp; package Point;<br> &nbsp; use Moose;<br> &nbsp; use Exporter 'import';<br> &nbsp; our @EXPORT;<br> &nbsp; has 'x' =&gt; ( 'is' =&gt; 'rw' );<br> &nbsp; has 'y' =&gt; ();</p><p> &nbsp; sub clear {<br> &nbsp; &nbsp; &nbsp; &nbsp; my $self = shift;<br> &nbsp; &nbsp; &nbsp; &nbsp; {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $self-&gt;{'x'} = 0;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $self-&gt;y(0)<br> &nbsp; &nbsp; &nbsp; &nbsp; }</p><p> &nbsp; }<br> &nbsp; 1;</p><p>This is in the development version of v6.pm - not in CPAN yet.</p> fglock 2006-06-30T19:09:04+00:00 journal more v6 http://use.perl.org/~fglock/journal/30031?from=rss <p>I'm preparing v6.pm for release with next version of Pugs. I'm taking care this time, so that people don't think it's a complete implementation - it's not at all.</p><p>There are quite a few problems ahead:</p><p>- the compiler is currently slow to load - this is fixable, but it takes some work.</p><p>- integrating P6 syntax in Pugs::Compiler::Rule will create a circular dependency with v6.pm</p><p>- v6 needs support for multis (multisub, multimethod), types, advanced OO (the plan is to use Stevan's Moose.pm), coroutines, and all the P6 goodies that are not native to P5.</p><p>v6.pm is mostly about syntax - all the semantics must be provided by external modules.</p><p>About the old 'lrep' script - I think I'll rewrite it as a thin v6.pm wrapper, just because I find it a cool name.</p> fglock 2006-06-25T03:39:38+00:00 journal use v6-pugs http://use.perl.org/~fglock/journal/29977?from=rss <p>Today I plan to rename Pugs-Grammar-Perl6 to Pugs-Compiler-Perl6, and start adding the glue code to make it work.</p><p>The first goal is to allow perl 5 to execute this:</p><p> &nbsp; &nbsp; use v6-pugs;<br> &nbsp; &nbsp; "hello, world".say;</p><p>This should either execute immediately, if called with '-e', or create a<nobr> <wbr></nobr>.pmc file containing:</p><p> &nbsp; &nbsp; print "hello, world", "\n";</p><p>url: http://svn.openfoundry.org/pugs/misc/pX/Common/</p><p>The same code could be compiled to use Inline::C instead of plain perl.</p><p>update: the module is now called 'P6.pm', because 'v6' didn't work in perl 5.</p><p>update 2: the module is finally named 'v6.pm', but it is used 'v6-pugs' - and it works fine - thanks Audrey!</p> fglock 2006-06-20T13:39:06+00:00 journal