Bernhard's Journal Bernhard'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:24:44+00:00 pudge Technology hourly 1 1970-01-01T00:00+00:00 Bernhard's Journal Basic OO-features in Pipp <p> When starting on the ReflectionExtension class for Pipp, I got reminded that some very basic OO-features were not working yet. The good think is that I can all that stuff from Rakudo. So simple inheritance and reading member of class instances are working now. </p><p> I also simplified my Test.php. The current test number is now tracked in a global variable. Before that change, the test number had to be passed in from the test script. </p> Bernhard 2009-06-24T13:35:34+00:00 journal My first PHP extension <p> PHP Extensions are usually written C and they usually export at least one constant, function, class, resource type or stream to the PHP userspace. So they are pretty much the same as XS-Modules in Perl 5. Extensive information about PHP extension can be found in Sara Golemons book 'Extending and Embedding PHP'. </p><p> The several hundred standard functions of PHP are implemented in terms of extensions. Pipp, <a href=""></a>, either needs to reimplement this massive count of functions, or support extensions natively. Being lazy, native support for extensions is the way to go. So let's see how to create a dummy PHP extension. The following is for Linux and is based on the tutorial <a href=""><nobr>H<wbr></nobr> P-and-Zend</a>. </p><p> The first step is to build PHP 5.3 with development support. The source can be checked out from a CVS repository. See <a href=""></a> for details and the password for anonymous CVS access.</p><blockquote><div><p> <tt>&nbsp; mkdir ~/first_php_extension<br>&nbsp; cd ~/first_php_extension<br>&nbsp; cvs -d<nobr> <wbr></nobr> login<br>&nbsp; cvs -d<nobr> <wbr></nobr> checkout -r PHP_5_3 php5</tt></p></div> </blockquote><p>Buildconf performs some checks and creates a configure script for the GNU autotools. 're2c' is the parser generator used by PHP 5.3. It is not build dependency, as the generated C-files are in the repository. There is also a message about 'autotools 2.13' being recommended, but I simply ignore that.</p><blockquote><div><p> <tt>&nbsp; cd ~/first_php_extension/php5<br>&nbsp;<nobr> <wbr></nobr>./buildconf</tt></p></div> </blockquote><p>For building extensions we need an installed PHP and it's associated helper scripts. Let's install our new PHP next to the source, so that the system PHP is left undisturbed.</p><blockquote><div><p> <tt>&nbsp; mkdir ~/first_php_extension/installed<br>&nbsp;<nobr> <wbr></nobr>./configure --prefix=/home/bernhard/first_php_extension/installed --enable-debug --enable-maintainer-zts --enable-embed<br>&nbsp; make test<br>&nbsp; make install<br>&nbsp; export PATH=~/first_php_extension/installed/bin:$PATH</tt></p></div> </blockquote><p>This should leave us with PHP 5.3 with debug support.</p><blockquote><div><p> <tt>&nbsp; bernhard@heist:~/first_php_extension/php5$ php --version<br>&nbsp; PHP 5.3.0RC3-dev (cli) (built: Jun&nbsp; 7 2009 12:36:41) (DEBUG)<br>&nbsp; Copyright (c) 1997-2009 The PHP Group<br>&nbsp; Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies</tt></p></div> </blockquote><p> The next step is to create a dummy extension without specific functionality. The helper script 'ext_skel' creates a stub in the directory 'pipp_sample'.</p><blockquote><div><p> <tt>&nbsp; cd ~/first_php_extension/php5/ext<br>&nbsp;<nobr> <wbr></nobr>./ext_skel --extname=pipp_sample</tt></p></div> </blockquote><p>For now I leave pipp_sample.c alone, but config.m4 needs to be edited. Instructions can be found in config.m4 itself, I ended up with uncommenting the lines 16, 18, 60.</p><blockquote><div><p> <tt>&nbsp; cd ~/first_php_extension/php5/ext/pipp_sample<br>&nbsp; vi config.m4</tt></p></div> </blockquote><p>The helper phpize takes info from the PHP installation and creates more files, including a configure script.</p><blockquote><div><p> <tt>&nbsp; phpize</tt></p></div> </blockquote><p>Now the dummy extension can be configured and compiled.</p><blockquote><div><p> <tt>&nbsp;<nobr> <wbr></nobr>./configure --enable-pipp_sample<br>&nbsp; make test</tt></p></div> </blockquote><p>A sanity test can be done with:</p><blockquote><div><p> <tt>&nbsp; php pipp_sample.php</tt></p></div> </blockquote><p>Now let's copy the generated shared lib for use by the installed PHP.</p><blockquote><div><p> <tt>&nbsp; make install</tt></p></div> </blockquote><p>The shared library could also be load by Pipp. Let's take a look at the function.</p><blockquote><div><p> <tt>&nbsp; bernhard@heist:~$ nm<nobr> <wbr></nobr>/home/bernhard/first_php_extension/installed/lib/php/extensions/debug-zts-20090<nobr>1<wbr></nobr> 15/ | grep ' U '<br>&nbsp; U php_info_print_table_end<br>&nbsp; U php_info_print_table_header<br>&nbsp; U php_info_print_table_start<br>&nbsp; U spprintf<br>&nbsp; U zend_parse_parameters</tt></p></div> </blockquote><p>The undefined functions are provided by the PHP extension API. These are also the functions that need to be implemented for Pipp. </p> Bernhard 2009-06-07T11:45:24+00:00 journal Declaring lexicals within $sth-bind_columns() Lately I have taken on the maintainance of a legacy Perl 5 script. The script heavily uses the DBI function bind_columns() for retrieving data from a relational database. After some refaktoring I ended up with something like this:<blockquote><div><p> <tt>my $sth = $dbh-&gt;prepare(&lt;&lt;'END_SQL');<br>SELECT color, food, num_legs<br>&nbsp; FROM pet<br>END_SQL<br>my ( $food, $something_else, $color, $num_legs);<br>$sth-&gt;bind_columns( \$color, \$food, $num_legs );</tt></p></div> </blockquote><p>Not being entirely happy with I went one step further and got:</p><blockquote><div><p> <tt>my $sth = $dbh-&gt;prepare(&lt;&lt;'END_SQL');<br>SELECT color, food, num_legs<br>&nbsp; FROM pet<br>END_SQL<br>$sth-&gt;bind_columns( \( my ( $color, $food, $num_legs) ) ):<br>my ( $something_else );</tt></p></div> </blockquote><p>This style enforces some structure in the declaration. Is there a way to make this really nice? Installing a module is no option in this context.</p> Bernhard 2009-03-05T20:27:57+00:00 journal Pipp has left the nest and moved to github <p> Pipp, that is PHP on Parrot, has moved to github, <a href=""></a>. </p><p> I have not yet tested with an installed Parrot yet. So for now please check out Pipp in a Parrot source dir. See <a href=""></a> for details. </p><p> If you want to play with a cooler language than PHP, then take a look at <a href=""></a>. </p> Bernhard 2009-02-15T13:18:07+00:00 journal Moved Unlambda and Lazy K to github <p> <b>Unlambda</b>, <a href=""></a>, and <b>Lazy K</b>, <a href=""></a>, are two pure functional esoteric programming languages. Leo T&#246;tsch implemented them for Parrot. As language implementation are encouraged to leave the nest, I moved them over to Github, <a href=""></a>. </p><p> See <a href=""></a> for the current list of languages for Parrot. </p> Bernhard 2009-01-25T20:15:01+00:00 journal Parrot m4 has left the nest <p> Parrot m4 is an incomplete implementation of GNU m4 on top of parrot. As language implementations are encouraged to leave Parrot's svn, I have moved the code and the history over to <a href=""></a>. The source can easily be fetched by typing 'make co-m4' in the 'languages' directory of a Parrot working copy. </p><p> I am no longer working on m4, so anybody is welcome to clone it. However I think that porting GNU m4 to Perl 6 would be the more interesting task these days. </p><p> The mostly up-to-date list of Parrot HLLs is at <a href=""></a>. </p> Bernhard 2009-01-18T12:38:41+00:00 journal HQ9+ left the nest <p> HQ9+, <a href=""></a>, is a little language the makes a few things easy, and almost all other things impossible. </p><p> There is an implementation of HQ9+ for Parrot that is based on the Parrot Compiler Toolkit. For getting my feet wet with git, it moved the source code from Parrot's svn repository to <a href=""></a>. The migration went very smoothly and git made a good initial impression on me. The instructions on were very helpful. Details on the migration are on <a href=""></a>. </p><p> In this migration I simply discarded the svn commit history. For moving other languages to git, it would be handy to have a complete and current git mirror of Parrot's svn repository. </p> Bernhard 2009-01-12T21:58:25+00:00 journal Closures for Pipp <p> In the last days I have been working on supporting closures for Pipp. Yes, you've read correctly. The next version of PHP will support real closures. See <a href=""><nobr>c<wbr></nobr> a=drs-tp5008</a> for a nice writeup. </p><p> Closures are connected with lexical variables, so I had I had to rethink the way I handle variables in Pipp. Initially I had the variables outside functions as package variables. Since this doesn't play well with closures, and as there are problems with included files, I changed those to lexical variables. This was the major part of the work. Thanks to Patrich Michaud for advising me where I should define the lexicals. </p><p> After switching to lexicals everywhere I followed my usual approach and tried to do the same as Rakudo does. This worked without hassle for a simple case.</p><blockquote><div><p> <tt>&lt;?php<br> <br>&nbsp; function gen_indentor ( ) {<br>&nbsp; &nbsp; &nbsp; $indention = '+';<br>&nbsp; &nbsp; &nbsp; $indentor = function ($line) use ($indention) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo $indention . $line . "\n";<br>&nbsp; &nbsp; &nbsp; };<br> <br>&nbsp; &nbsp; &nbsp; return $indentor;<br>&nbsp; }<br> <br>&nbsp; $sub_1 = gen_indentor();<br> <br>&nbsp; $sub_1('one plus');<br> <br>?&gt;</tt></p></div> </blockquote><p>correctly gives:</p><blockquote><div><p> <tt>+one plus</tt></p></div> </blockquote><p>But when I create a second closure I run into problems.</p><blockquote><div><p> <tt>&lt;?php<br> <br>&nbsp; function gen_indentor ($indention) {<br>&nbsp; &nbsp; &nbsp; $indentor = function ($line) use ($indention) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo $indention . $line . "\n";<br>&nbsp; &nbsp; &nbsp; };<br> <br>&nbsp; &nbsp; &nbsp; return $indentor;<br>&nbsp; }<br> <br>&nbsp; $sub_1 = gen_indentor('+');<br>&nbsp; $sub_4 = gen_indentor('++++');<br> <br>&nbsp; $sub_1('one plus');<br>&nbsp; $sub_2('four plusses');<br> <br>?&gt;</tt></p></div> </blockquote><p>incorrectly gives:</p><blockquote><div><p> <tt>++++one plus<br>++++four plusses</tt></p></div> </blockquote><p>Looks like I need to fiddle some more.</p> Bernhard 2009-01-01T16:57:22+00:00 journal Pipp is now more boring <p> Comparing different parsing and tree transformation techniques was for me a major reason for starting work on Pipp. Therefore Pipp had until now support for different frontends: </p><dl> <dt>Antlr 3</dt><dd>Parsing and tree transformation with Java-based Antlr 3</dd><dt>PHC</dt><dd>Take XML-output from phc and transform it with XSLT</dd><dt>PCT</dt><dd>Parrot Compiler Toolkit</dd></dl><p> Lately I found that I only worked on the PCT variant. So in order to keep it simple, especially for new contributors, I removed support for Antlr3 and PHC. </p><p> So, Pipp is now more boring, but other exciting things are coming. </p> Bernhard 2008-12-21T12:04:53+00:00 journal Rewriting Pipp tests in PHP <p>Pipp is Parrot's PHP and it has small test suite that lives alongside the code in the Parrot repository. Most of the test scripts are written in Perl 5 using the Parrot::Test modules. So usually I tell Pipp to run some PHP code and check whether the expected result is printed. This works fine but is not very exiting. </p><p> More exciting, for some definition of exciting, is to run PHP scripts and emit TAP with a testing lib implemented in PHP. So Pipp this needs </p><ol> <li>user defined functions with param passing</li><li> <b>global</b> for keeping track of the running test count</li><li>module loading</li></ol><p> Stealing from Rakudo I now got most of that. <b>global</b> is still missing, so currently I pass in the current test number and increment it outside the testing functions. </p><p> Over the next days I plan to port a selection of the easier scripts to PHP. Things like TODO, SKIP and regex matching have to wait for later. Takers welcome! </p> Bernhard 2008-11-27T20:36:12+00:00 journal Attended talk about Enterprise 2.0 <p> Wednesday night I attended a talk entitled "Enterprise 2.0 &#8211; Die Kunst, loszulassen". I didn't expect much of the talk, as I primarily went there for meeting people. But I was pleasently surprised, as the speaker Wilms Buhse did an excellent talk. He really made his point, that the lessons learned from social networks can be applied to enterprises. His examples were the experiences at CoreMedia and with </p><p> The other thing I learned at the Forum is that Dresden is really a nice City. I just didn't find the sweet spots when I went there. </p> Bernhard 2008-11-14T12:35:57+00:00 journal Parrot 0.6.4 <p>On behalf of the Parrot team, I'm proud to announce Parrot 0.6.4 &quot;St. Vincent Amazon.&quot; <a href="">Parrot</a> is a virtual machine aimed at running dynamic languages.</p><p>Parrot 0.6.4 is available via <a href="">CPAN</a> (soon), or <a href="">follow the download instructions</a>. For those who would like to develop on Parrot, or help develop Parrot itself, we recommend using <a href="">Subversion</a> on <a href="">our source code repository</a> to get the latest and best Parrot code.</p><p>Parrot 0.6.4 News:</p><blockquote><div><p> <tt>- Documentation<br>&nbsp; + removed a lot of old information from the FAQ<br>&nbsp; + improved function level documentation<br>- Configuration<br>&nbsp; + removed the configuration item 'has_gnu_m4'<br>&nbsp; + refactored ICU-detection<br>- Languages<br>&nbsp; + ChitChat<br>&nbsp; &nbsp; - improved the Smalltalk implementation<br>&nbsp; + Pipp<br>&nbsp; &nbsp; - renamed Plumhead to Pipp<br>&nbsp; &nbsp; - support for a lot of builtin functions.<br>&nbsp; &nbsp; - Pipp now uses PHP specific data types.<br>&nbsp; &nbsp; - converted from PCT with TGE to PCT with NQP actions<br>&nbsp; &nbsp; - improvements in the PCT variant by using optok parsing<br>&nbsp; &nbsp; - start of object support<br>&nbsp; + pir<br>&nbsp; &nbsp; - simple assignments work<br>&nbsp; + json<br>&nbsp; &nbsp; - added a PCT-based implementation of JSON parsing<br>&nbsp; + lolcode<br>&nbsp; &nbsp; - improved handling of symbols<br>&nbsp; &nbsp; - added support for block handling<br>&nbsp; &nbsp; - added support for globals<br>&nbsp; + Lua<br>&nbsp; &nbsp; - more tests<br>&nbsp; + Rakudo<br>&nbsp; &nbsp; - updated Range implementation<br>&nbsp; &nbsp; - added enums<br>&nbsp; &nbsp; - added generic type declarations (::T)<br>&nbsp; &nbsp; - added runtime mixing of roles with 'does' and 'but'<br>&nbsp; &nbsp; - added generic type declarations<br>&nbsp; &nbsp; - fixed handling of implicit lexicals ($_, $!, and $/)<br>&nbsp; &nbsp; - fixed implicit method calls on $_<br>&nbsp; &nbsp; - improved complex math builtins, added Complex<br>&nbsp; &nbsp; - moved many builtins to class Any<br>&nbsp; &nbsp; - declaration of lists of variables now work<br>&nbsp; &nbsp; - improved test infrastructure<br>&nbsp; &nbsp; - 910 additional passing spec tests since last release<br>&nbsp; &nbsp; - more convergence with grammar<br>&nbsp; &nbsp; - added named 0-ary parsing and ops<br>- Compilers<br>&nbsp; + PCT:<br>&nbsp; &nbsp; - allowed subroutine and method names to be a PAST tree that produces the name<br>&nbsp; &nbsp; - Improved lexical handling<br>- Tools<br>&nbsp; + pbc_disassemble renamed from disassemble<br>- Implementation<br>&nbsp; + allowed<nobr> <wbr></nobr>.macro_const in PIR<br>&nbsp; + added the flag<nobr> <wbr></nobr>:lexid(...) for subroutines<br>&nbsp; + made multiple dispatch work for sub types<br>&nbsp; + fixed garbage collection bug related to the metadata attached to a PMC_EXT structure<br>&nbsp; + added a warning when using deprecated opcodes<br>&nbsp; + simplified the stacks implementation<br>&nbsp; + fixed C++ build<br>&nbsp; + improved closure and lexical support<br>&nbsp; + improved IMCC register allocator<br>&nbsp; + added cache for all runtime-constant strings, reducing memory usage<br>- Miscellaneous<br>&nbsp; + improved OpenGL/GLU/GLUT bindings<br>&nbsp; + added a standard profile for Perl::Critic coding standard testing<br>&nbsp; + added support for smoke testing with Smolder<br>&nbsp; + enabled use of Test::Harness 3.0 if available, but don't require it for 'make test'<br>&nbsp; + added the executable 'parrot_config' to query Parrot configuration</tt></p></div> </blockquote><p>Thanks to all our contributors for making this possible, and our sponsors for supporting this project. Our next release is 19 Aug 2008.</p><p>Enjoy!</p> Bernhard 2008-07-15T11:17:32+00:00 parrot Welcoming Pipp <p> The PHP on Parrot implementation used to be called Plumhead, after the Plum-Headed Parakeet. As this name is somewhat goofy, a new name was sought. Some more or less sane variants were discussed, <a href=""></a>. </p><p> And the winner is <b>Pipp</b>. </p><p> Thanks to Christoph Otto for getting this rolling. </p> Bernhard 2008-07-02T15:26:03+00:00 journal Eclectus now emits Not Quite Perl6 <p> Eclectus is a Scheme-compiler implemented in Scheme. The compilation target is a Parrot Abstract Syntax Tree, which is being run with the help of the Parrot Compiler Toolkit. </p><p> A sideline in Eclectus is the the problem how to tell PCT about the PAST generated in Scheme. Up to now I generated PIR that built up that data structure. This involved nasty dealings with unique ids for Parrot registers. </p><p> Generating NQP is much saner. The PAST is now set up with nested PAST::Node constructors. </p><p> Even nicer would be to create a YAML representation of PAST. But PCT doesn't support this yet. </p> Bernhard 2008-05-01T10:32:54+00:00 journal HQ9+ reimplemented with PCT <p> Klaas Jan's excellent "Parrot Compiler Tools" - Tutorial inspired me to go back and reimplement HQ9+ with PCT. The result is in <a href=""></a>. </p><p> As HQ9+ is not really a hard language, it all went fairly smooth. '' created me a stub in 'languages/hq9plus'. Then I copied some reusable files from the old implementation in 'languages/HQ9plus'. This was fine under Linux, but caused pain for folks on case-insensitive file systems. Sorry, next time I try to think before committing! </p><p> For looking up snippets of PAST I used the old trick: write a snippet of Perl 6 and look at the PAST that Rakudo generates. </p><p> The last problem was whitespace handling. For that I only needed a simple change in the grammar. Replace all 'rule's by 'token's and sprinkle some '\s*'s. </p><p> The next thing on my agenda is for Plumhead and Eclectus. I want to switch from 'generate PIR that sets up PAST' to 'generate NQP that sets up PAST'. </p> Bernhard 2008-04-02T19:05:37+00:00 journal Parrot 0.6.0 "P&amp;P" released <p>On behalf of the Parrot team, I'm proud to announce Parrot 0.6.0 &quot;P&amp;P.&quot; <a href="">Parrot</a> is a virtual machine aimed at running dynamic languages. This release is a milestone release featuring the revamping of Parrot Magic Cookies.</p><p>Parrot 0.6.0 can be obtained via <a href="">CPAN</a> (soon), or <a href="">follow the download instructions</a>. For those who would like to develop on Parrot, or help develop Parrot itself, we recommend using <a href="">Subversion</a> or <a href="">SVK</a> on <a href="">our source code repository</a> to get the latest and best Parrot code.</p><p>Parrot 0.6.0 News:</p><blockquote><div><p> <tt>- Specification<br>&nbsp; + launched pdd18_security.pod<br>&nbsp; + updated pdd17_pmc.pod<br>&nbsp; + launching draft of pdd28_character_sets.pod<br>- Documentation<br>&nbsp; + cleanup of IMCC documentation<br>- Configuration<br>&nbsp; + add step auto::gettext<br>&nbsp; + add step auto::crypto<br>- Compilers<br>&nbsp; + PCT:<br>&nbsp; &nbsp; . Fix '-e' option<br>&nbsp; &nbsp; . Phase out P6Regex in favor of Perl6Regex<br>&nbsp; + IMCC:<br>&nbsp; &nbsp; '.local Array my_arr' is illegal now<br>- Languages<br>&nbsp; + C99: reimplementation with PCT<br>&nbsp; + lolcode:<br>&nbsp; &nbsp; . various updates<br>&nbsp; &nbsp; . add support for functions with params<br>&nbsp; &nbsp; . add math functions<br>&nbsp; + Rakudo:<br>&nbsp; &nbsp; . support for 'say'<br>&nbsp; &nbsp; . first cut at smart matching<br>&nbsp; &nbsp; . indirect method calls<br>&nbsp; &nbsp; . support for Pairs<br>&nbsp; &nbsp; . added methods 'grep' and 'first'<br>&nbsp; &nbsp; . implement auto{increment,decrement}<br>&nbsp; &nbsp; . initial implementation of 'perl6doc'<br>&nbsp; + Lua:<br>&nbsp; &nbsp; . various updates<br>&nbsp; &nbsp; . add base64 library<br>&nbsp; + Cardinal: basic support for functions with parameters<br>&nbsp; + Pheme: various updates<br>&nbsp; + Ecmascript: various updates<br>&nbsp; + Tcl: now targeting tcl 8.5.1, no more expected failures in test suite.<br>&nbsp; &nbsp; (No, this doesn't mean everything's implemented. =-)<br>&nbsp; + Eclectus: various updates<br>&nbsp; + WMLScript: various updates<br>- Implementation<br>&nbsp; + PDD17 (PMCs)<br>&nbsp; + Add library YAML::Dumper<br>&nbsp; + Add the MD2, MD4, MD5, RIPEMD160, SHA &amp; SHA1 PMC, as a wrapper<br>&nbsp; &nbsp; &nbsp;around libcrypto<br>- Miscellaneous<br>&nbsp; + various bugfixes, code cleanups and coding standard fixes<br>&nbsp; + consting<br>&nbsp; + remove external Perl 5 modules from the Parrot distribution</tt></p></div> </blockquote><p>Thanks to all our contributors for making this possible, and our sponsors for supporting this project.</p><p>Enjoy!</p> Bernhard 2008-03-18T21:19:10+00:00 parrot Techtip of the week When being shocked that your notebook is kaputt, as it apparently gets no power, please make sure that you are using the correct power supply. There are plugs with a slightly wider inner diameter. Bernhard 2008-02-25T20:09:55+00:00 journal Parrot Abstract Syntax Tree in Scheme-XML <p> As I'm hacking away at Eclectus, Scheme on Parrot in Scheme, I'm starting to pick some Scheme knowledge. So before implementing new features I employed my new wisdom and did some refactoring on my Scheme code. </p><p> The most nasty thing in compiler.scm was the generation of PIR while traversing the to-be-compiled s-expression. I decided to use XML Infoset as an intermediate representation, as I already have an XSLT sheet for generating a PIR representation of PAST from an XML representation of PAST. The nice thing is that the XML infoset can also be represented as a Scheme s-expression, that is SXML. The Scheme librarx SSAX-SXML can turn SXML into XML and perform XSLT operations. </p><p> For an example let's look at the Scheme form:</p><blockquote><div><p> (fx+ (fx+ -10 11) (fx+ (fx+ 4 3) (fx+ 3 3)))</p></div> </blockquote><p> In Perl 5 this could be expressed:</p><blockquote><div><p> say ( (-11 10) + ( (4 + 3) + (3 + 3)));</p></div> </blockquote><p> Represented as SXML this becomes: <code> (|PAST::Stmts| (|PAST::Op| (|@| (pasttype "call") (name "say")) (|PAST::Op| (|@| (pirop "n_add")) (|PAST::Op| (|@| (pirop "n_add")) (|PAST::Val| (|@| (value -10) (returns "EclectusFixnum"))) (|PAST::Val| (|@| (value 11) (returns "EclectusFixnum")))) (|PAST::Op| (|@| (pirop "n_add")) (|PAST::Op| (|@| (pirop "n_add")) (|PAST::Val| (|@| (value 4) (returns "EclectusFixnum"))) (|PAST::Val| (|@| (value 3) (returns "EclectusFixnum")))) (|PAST::Op| (|@| (pirop "n_add")) (|PAST::Val| (|@| (value 3) (returns "EclectusFixnum"))) (|PAST::Val| (|@| (value 3) (returns "EclectusFixnum"))))))))) </code></p> Bernhard 2008-01-06T18:30:34+00:00 journal Plumhead and Eclectus <p> I'm inching forward with Plumhead, PHP on Parrot, and Eclectus, Scheme on Parrot. </p><p> Both have been converted to use the shiny new Parrot Compiler Toolkit. I don't use NQP yet, but being able to use Perl6 for compiler and library implementation is sooo sweet. Kudos to Patrick Michaud. </p><p> On the Plumhead side, Jeff Horwitz did some brave hacking and added Plumhead to mod_parrot. See <a href=""></a> </p> Bernhard 2007-12-09T20:33:00+00:00 journal Introducing Eclectus <p> When working on 'languages/scheme' in the Parrot repository I got estranged with using Perl5 for implementing Scheme on Parrot. It sure does the job, but I want to learn about Lisp, not about Arrays of Arrays in Perl 5. </p><p> I came across <i>An Incremental Approach to Compiler Construction</i> at <a href=""></a>. This is a Scheme to x86 assembly compiler, implemented in Scheme. The cute thing is that the compiler construction is done in small steps. Every step constitutes a working compiler for a larger subset of Scheme. So I stared to work on Eclectus, a bootrapping Scheme to PBC compiler. </p><p> For pictures ses <a href=""></a> </p> Bernhard 2007-11-17T17:14:37+00:00 journal Teaching myself Scheme <p> In the last weeks I have been neglecting Plumhead, that is PHP on Parrot. Instead I have been concentrating on learning about Common Lisp and Scheme. Currently I'm working my way through a nice Scheme tutorial, <cite>Teach Yourself Scheme in Fixnum Days</cite> <a href=""></a>. I try to make the tutorial examples work in 'languages/scheme', a Scheme on Parrot implementation from Jeff Goff. </p><p> I also got me a copy of <cite>Lisp in small pieces</cite>. But I found that it's better to know a little bit of Scheme, before starting to delve into that. </p> Bernhard 2007-10-31T19:09:14+00:00 journal Seen on reddit: What large websites are running on Seen on<br> <i>What nine of the world&#8217;s largest websites are running on</i> <a href=""></a>.<br> Perl has a strong showing. However the selection of sites has been debated. <a href=""></a> <br> The data for the table was scraped from <a href=""></a> Bernhard 2007-10-02T08:25:08+00:00 journal Bitflip error <p> On Friday a colleague @work asked me about an error in a webapplication. There was a Perl syntax error in Sys::Hostname. As I saw no reason that anybody should mess with with Sys::Hostname, I checked the time was last changed. Confusingly the last change was in 2004, apparently this was the time the server was set up. A diff with another Perl 5.8.0 installation showed a single bit change. The first space, 0x20, of line 104 has turned into into a '(', 0x28. The only explanation I can imagine is that a bit has flipped in file cache. </p><p> <em>Strange.</em> </p> Bernhard 2007-06-24T20:22:00+00:00 journal Choosing a license for Plumhead <p> I have been thinking on how to proceed with Plumhead, that is PHP on Parrot. The problem is that I have neither the ability nor the inclining to write a PHP grammar from scratch. So a template is needed. This brings up the question of licensing. </p><p> Johnlim's blog <a href=""></a> got me jumpstarted on which PHP implementations are out there. I have put my finding into the Parrot Wiki, <a href=""></a>. The projects that look most interesting to me are phc, PHP4Mono and Roadsend. The PHP4Mono and the Roadsend grammars seem to be written from scratch. Both projects are GPL licensed. The phc grammar is derived from the PHP 5.2 grammar. </p><p> PHP 5.2 is licensed under the PHP license, while parts are under the Zend license. Both licenses are BSD-like, which is quite acceptable to me. </p><p> So the plan of the day is to derive the Plumhead grammars from the PHP 5.2 grammar. I'm not sure whether that means that I need to put the whole of Plumhead under BSD license, or whether I can stick with Artistic+GPL. </p> Bernhard 2007-04-09T20:19:16+00:00 journal Triboluminescence <p> Tonight I was opening a sealed envolope in dim light. When opening the envelope I noticed blueish flashes of light where the adhesive was pulling apart. Subconciously I probably was looking out for that, as I already had noticed the phemenomen some years ago. </p><p> Googling told me that this effect in called Triboluminescence <a href=""></a>, which means 'light from rubbing'. Apparently this is one of the messier phemenomens. At least three different mechanisms were suggested. Breaking of polymers, squashing of crystals and surface excitations. During my study of physics I never came accross it. The closest thing was the piezoelectric effect, which has a lot of technical applications. </p><p> If I don't forget about it, I'll get me some sugar cubes and crush them in the dark. </p><p> PS: Is there a something like a TinyMCE for use.perl ? Typing all that markup is tiring. </p> Bernhard 2007-02-15T21:44:02+00:00 journal More Plumheads <p> Lately I have expanded the scope of <b>P</b>lum<b>H</b>eaded <b>P</b>arakeet. The current plan is to have a side-by-side comparison of differend parsing and transformation techniques. These techniques are: </p><dl> <dt>PHC</dt> <dd>Take XML output of phc, <a href=""></a>, and transform it with XSLT.</dd><dt>ANTLR3</dt><dd>Write parser and treegrammar in ANTLR3, <a href=""></a>, with Java backend</dd><dt>Partridge</dt><dd>Use the Parrot compiler tools for parsing and transformation</dd></dl><p> The transformation target is in all three PAST-pm, an abstract syntax tree that can be trasformed into Parrot bytecode. </p><p> See also <a href=""></a> </p> Bernhard 2007-01-16T23:03:06+00:00 journal MIME::Base64 <p>After starting on Plumhead, aka <strong>P</strong>lum<strong>H</strong>eaded <strong>P</strong>arakeet, I stumbled on base64 encoded strings embedded in the XML emitted by phc <a href=""></a>.</p><p>The plan is to create Parrot Intermediate Representation from XML. So I became sidetracked into making a MIME::Base64 module for PIR. As usual it took longer than expected, even though I found a nice german tutorial, <a href=""></a><br>So an incomplete implementation is now at <a href=""></a><nobr>.<wbr></nobr> <br>The tests I stole from the Perl5 module MIME::Base64. Thanks to Will Coleda for compilers/json, which helps in setting up the test cases.</p> Bernhard 2006-10-12T21:42:46+00:00 journal Plum-headed Parakeet <p>Mark Overmeer passed on one of the take home messages from YAPC::Europe in Birmingham. In a lightening talk about XML::Compile, <a href=""></a>, he said something like: <cite>Never mind the XML, it's just syntax.</cite> The day before, Allison Randall had talked about the Parrot compiler tools and mentioned how XSLT had influenced the design of TGE. So I wondered whether <cite>Never mind the XSLT, it's just syntax.</cite> applies as well. </p><p> The XSLT project I came up with, is to take the XML output of phc, <a href=""></a> and transform it to something Parrot can understand. phc parses PHP, so this should become an implementation of PHP on Parrot. </p><p> As a projectname, <a href=""></a>, I chose 'Plumhead', which is short for <b>P</b>lum-<b>h</b>eaded <b>P</b>arakeet, <a href=""></a>. The description on Wikipedia is neat too: <cite>Plum-headed Parakeet is a gregarious and noisy species with range of raucous calls.</cite> </p> Bernhard 2006-09-09T21:24:56+00:00 journal May 2006 Munich Perl Monger meeting <p> Last night the Munich Perl Mongers celebrated the second installment of the bimonthly meeting. Harald J&#246;rg, the MPM fearless leader, suggested a 'Man Fat, a chinese restaurant in Schwabing as the stomping ground. The food was tasty and the wheatbeer was most welcome after the bike ride from $work at the other end of town. </p><p> Besides 7 regulars, two new faces showed up: another J&#246;rg, of Perl golf fame, and Susanne Ruppel. Susanne got the rocks rolling by suggesting to bid for the German Perl Workshop 2007. As the enthusiasm is there, it was decided to go for it! In 2002, when we hosted the YAPC::EU, only Norbert Gr&#252;ner really knew what we were getting into. This time we have no excuses. </p> Bernhard 2006-05-18T21:50:57+00:00 journal Munich Perl Monger meeting <p> In a radical breach of tradition, the Munich Perl Mongers decided to have regular bimonthly meetings. In order to limit the culture shock, the location will remain dynamic and will be chosen in feverish indecision. </p><p> So yesterday evening was the first regular meeting. Five Mongers showed, including a new face, Gertraud. Harald J&#246;rg has a writeup in German, <a href=""></a>. Topics ranged from using 'ed' on appliances to the job prospects of assembler programmers for BS2000. </p><p> The MPM schedule is the third wednesday of uneven months. When in doubt consult the perlgolf entries in <a href=""></a>. </p><p> On the Parrot side, I hope to teach ANTLR 3 more about bc. And coming saturday I plan to attend the 'Linux Info Tag' in Augsburg, enjoying Ingo Blechschmidt's talk 'Perl6 genau jetzt'. </p> Bernhard 2006-03-16T19:51:37+00:00 journal