autrijus's Journal http://use.perl.org/~autrijus/journal/ autrijus'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:01:44+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 autrijus's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~autrijus/journal/ 302 moved http://use.perl.org/~autrijus/journal/28112?from=rss <p>The Pugs journal has moved from <a href="http://use.perl.org/~autrijus/journal/">my use.perl journal</a>&nbsp; to <a href="http://pugs.blogs.com/">http://pugs.blogs.com/</a>.</p><p>I have imported all the old posts; comments are not yet imported.</p> autrijus 2005-12-23T17:23:48+00:00 journal Day 268: [OT]. http://use.perl.org/~autrijus/journal/27759?from=rss Sorry about the deletion of the last journal entry; I had a minor personal crisis and the more rosy-coloured tone in that entry looked less true than it was. <p> I'm very grateful to have received the kind comments, and hope that the authors won't take offense of their removal. </p><p> I am $working my way out of this personal/financial hell, so I can arrive in<nobr> <wbr></nobr>.au this Friday in one piece. Judging from past experience, it should get better as soon as I'm not in<nobr> <wbr></nobr>.tw.<nobr> <wbr></nobr>;-)</p> autrijus 2005-11-28T01:55:06+00:00 perl6 Day 257: Massive yak-shaving. http://use.perl.org/~autrijus/journal/27600?from=rss Before I departed for Taipei, I had a very fruitful meeting with aevil and jhi, talked about all things CPAN, Unicode, P5/P6 interop, pumpkineering lessons, et al. <p> jhi gave me a heavy book, <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0201700522">Unicode Demystified</a>, which really made sense to me. I brought jhi's concerns to #parrot, mainly about the combinatorial explosive danger of introducing charsets other than ASCII/Latin1/Unicode, and the benefit of shifting away from UTF8 as internal encoding, by determining the optimal charset (i.e. 7/8/16/21 bits of Unicode) at PIR compilation time. Leo seems receptive, but more benchmark number is needed. </p><p> So I returned to<nobr> <wbr></nobr>.tw, abducted by Unicode Demystified, abused by jetlag (did lots of design work on paper as LCD made me doze off), as well as cleaning up the huge backlog of forgotten/repressed/misremembered commitments. </p><p> Then I was abducted by another fantastic book -- <a href="http://cc2e.com/">Code Complete 2nd Edition</a> -- which convinced me that this whole ten-day yakshaving was actually worth it. </p><p> Happily, my anxiety level now is at its all-time low in ten years, and commitment to Perl6/Pugs at its all-time high in ten months, so that's definitely improvement. More details later.<nobr> <wbr></nobr>:-)</p> autrijus 2005-11-16T18:29:30+00:00 perl6 Day 247: Final day at Liz's - Coroutines, siglists, rebindable bindings http://use.perl.org/~autrijus/journal/27490?from=rss Today is the last day of my stay at Liz and Wendy's. It was very enjoyable and productive, and I'm very grateful to their warm hospitality. <p> Liz and I had a SubEthaEdit session on coroutines today, with the brief notes merged to S17 (Liz is working on Englishify them at this moment). </p><p> Basically, a coroutine is an object that supports a<nobr> <wbr></nobr><code>.start</code> method that initiates the lightweight thread behind it, and return a object that may be manipulated like any other threads. If you call it like a nullary function, it activates the thread until it hits <code>yield</code>, in which case it gives the control back to the caller. The <code>return</code> inside the thread will end itself immediately. Either way, if you attempt to call a finished thread, an exception will be thrown. </p><p> Then we get the extra magic of calling a Coroutine objects like a Code object. This will trigger <code>&amp;Coroutine::postcircumfix&lt;( )&gt;</code>, which will take care of calling<nobr> <wbr></nobr><code>.start</code> again after the thread has finished, and arrange it so the next call to the coroutine will resume the ongoing thread instead of starting a new one. </p><p> Finally, there is the question of calling an ongoing coroutine with parameters. I think rebinding the parameters makes sense (as you can inhibit it using <code>is copy</code> or explicit <code>{ my $x<nobr> <wbr></nobr>:= $OUTER::x }</code>), but iblech's idea of having <code>yield</code> returning the Arglist makes sense too. In any case this is userland code, so one can change the behaviour with a trait or a subclass of Coroutines. </p><p> On the PIL2 front, I looked at the three special forms (Assignment, Binding, Apply) and decided to unify them into method calls, so the user can override them all inside the same object model -- "Everything is an object." </p><p> The Apply form is easiest, as it's just <code>method postcircumfix&lt;( )&gt;</code> that takes an Arglist and gives back an Arglist. See the new <a href="http://search.cpan.org/dist/Perl6-Bible/lib/Perl6/Bible/S03.pod">S03</a> for more about the cool things you can do with Arglists. </p><p> Assignment is also manageable under the container model. It will be <code>method infix:&lt;=&gt;</code> on Array, Hash, Scalar objects. The List objects constructed with <code>infix:&lt;,&gt;</code> will also respond to this method, to implement the <code>($a, $b, $c) = (1, 2, 3)</code> forms. </p><p> Binding almost feel like it should be a non-user-overridable special form, except we remembered the permanently-semi-official idea of Siglist objects, constructed with the<nobr> <wbr></nobr><code>:()</code> notation. It turns out that if we specify binding as a method on the Siglist object, and that the compiler desugars <code>LHS<nobr> <wbr></nobr>:= RHS</code> always as<nobr> <wbr></nobr><code>:(LHS).infix:&lt;:=&gt;(RHS)</code>, it will all Just Work. Under this regime, <code>3<nobr> <wbr></nobr>:= 4</code> will still be a compile-time error, as<nobr> <wbr></nobr><code>:(3)</code> would make no sense -- the macro that turns <code>sub (3) {...}</code> into <code>sub ($ where {$_ ~~ 3}) {...}</code> would not apply to bare Siglist construction forms. </p><p> So, PIL2 is looking good with fewer nodes and tighter object integration now. Maybe we are not yet at io's <a href="http://www.iolanguage.com/about/simplicity/">zero keywords</a> level, but it's getting dangerously close. Note that all of this is outside specced domain -- we'll need to work them back to Synopses and tests, and run them through p6l and @Larry. </p><p> Of course, to recover a respectible performance under this regime, we need to rely on optimizers, early binding, and/or type inference. But that's two milestones ahead, so let's get the dynamism part right first...</p> autrijus 2005-11-06T21:28:15+00:00 perl6 Day 246: Eighth day at Liz's - Parrot interop. http://use.perl.org/~autrijus/journal/27469?from=rss Today is the "Parrot is going to release tomorrow" day. The monthly release cycle is wonderful, as it ensures that the three Pugs/Parrot interops (embedding parrot, PGE rules, compiling to parrot) keeps working. <p> To that end, I fixed the Parrot codegen, removing deprecated opcodes and syntaxes. To my surprise and delight, I discovered that if I turn the parrotIsBrokenXXX flag to False, most tests in t/01-sanity/* still passes -- they used to break horribly, eaten alive by the rabid register alligator. </p><p> However, the new Parrot removed the ability to fake nested scopes with label-delimited inline closures, so some tests are now infinite-looping when compiled to Parrot. The correct (and easy) way to fix it would be using the new lexpad spec -- hopefully by Parrot 0.3.2 we will get both side implemented and work in harmony. </p><p> PGE got much more powerful with its ability to return anything, in addition to static Match objects. As a concrete demonstration, PGE now comes with a builtin <code>p6rule</code> rule that parses a Perl 6 rule string into a PGE::Rule object -- which will automagically appear in Pugs's <code>$/</code> as a hash object. To wit:</p><blockquote><div><p> <tt> pugs&gt; ('1' ~~<nobr> <wbr></nobr>/&lt;p6rule&gt;/)&lt;p6rule&gt;<br> Match.new(<br>&nbsp; &nbsp;ok =&gt; bool::true,<br>&nbsp; &nbsp;from =&gt; 0,<br>&nbsp; &nbsp;to =&gt; 1,<br>&nbsp; &nbsp;str =&gt; "1",<br>&nbsp; &nbsp;sub_pos =&gt; (),<br>&nbsp; &nbsp;sub_named =&gt;<br>&nbsp; &nbsp; &nbsp;{ "expr" =&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Match.new(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ok =&gt; bool::true,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from =&gt; 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;to =&gt; 1,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;str =&gt; "1",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sub_pos =&gt; (),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sub_named =&gt; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"type" =&gt; "term:",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"value" =&gt; "1"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;)<br>&nbsp; &nbsp; &nbsp;}<br> )</tt></p></div> </blockquote><p> Of course, it works for arbitrarily complex rules, not just a single character literal. </p><p> Note that we can't yet call the returned object's methods in Pugs, and there's no way to define rules using Perl 6 methods. This is because Pugs/Parrot doesn't really have a OO message protocol between them, and there are several complementary ways to solve this: </p><ul> <li>Implement calls to/from PMCs in embedded parrot, in the same way we tackled SVs in embedded Perl 5. This is trivial, but won't work with external Parrot (which is the only option in Win32 right now).</li> <li>Compile Perl 6 OO code that adheres to the object model to PIR. This would require MM/PIL2 and lexpad, but we are going to do them anyway.</li> <li>Port PGE to Perl 6. This is I hope what's going to happen in the long run, and will instantly carry the Rule engine to JavaScript and Perl5 runtimes, so it would be a net win.</li> <li>Port PGE to Haskell, and write translators between it and Parsec. This will net us a truly rebindable grammar in the Haskell runtime, and allows us to translate Pugs.Parser piecemeal to Rules, so it's also somewhat attractive.</li> </ul><p> On a completely unrelated note, gaal is writing an article for TPR (The Perl Review) about Pugs -- feel free to <a href="http://svn.openfoundry.org/pugs/docs/articles/tpr.pod">chime in</a>! (As usual, ask for a committer bit on freenode #perl6 if you hadn't got one.) </p><p> Last week's <a href="http://shibuya.pm.org/blosxom/techtalks/200511.html">Shibuya.pm meeting</a> features Catalyst, Ajax, Pugs and ICFP. Takesako-san did a <a href="http://labs.cybozu.co.jp/blog/takesako/pub/PugsPerl6-takesako.ppt">nice presentation</a> (PPT in Japanese) about Pugs, though some slides leaves me feeling excessively flattered.<nobr> <wbr></nobr>;-) </p><p> But now, happy in the knowledge that Parrot 0.3.0 can fly with Pugs interop intact, I'll go back to MM/PIL2 hacking ere sleep. See you tomorrow!</p> autrijus 2005-11-05T23:22:00+00:00 perl6 Day 245: Seventh day at Liz's - Madly hacking. http://use.perl.org/~autrijus/journal/27454?from=rss Vast number of good news and progress. However, as I'm in hyperfocus coding mode now, this journal is suffering quite a bit. So, some random links and thoughts: <ul> <li>Chip at last delivered a <a href="http://svn.perl.org/parrot/trunk/docs/pdds/pdd20_lexical_vars.pod">sane and wonderful</a> lexical pad spec for Parrot. I'm working on codegenning to it -- I wonder if Leo will beat me to it by implementing the spec.</li> <li>Patrick committed the long-anticipated <a href="http://svn.perl.org/parrot/trunk/compilers/pge/PGE/OPTable.pir">PGE::OPTable</a> precedence parser, and posted an <a href="http://www.nntp.perl.org/group/perl.perl6.compiler/1119">update</a> to P6C about it. This means we can finally start working on porting Parsec rules to Perl 6 rules, and bootstrap the previously-nonbootstrappable Parser component to Perl 6.</li> <li>I consulted with Stevan and iblech and decided that metamodel bootstrapping should be done only once, in the compiler; the compiler will serialize<nobr> <wbr></nobr>::Object and<nobr> <wbr></nobr>::Class as opaque objects. This alleviates the burden of runtime writers even more.</li> <li>I checked in code to make compile-time objects survive <code>pugs -CPugs</code> (and the trivial test-only <code>pugs -BPugs</code>), which makes pugscc applicable to most Perl 6 programs.</li> <li>To move beyond pugscc's native approach of serializing compiler state, I repo-copied PIL1 into PIL2, and started the long-overdue PIL renovation to support opaque objects, lexical hoisting, labels, pragmas, and other neat things that's long overdue. Sadly YARV can't help much here, as it doesn't seem to handle Ruby's BEGIN block.</li> <li>kane, liz and I did a bit SubEthaEdit on <a href="http://svn.perl.org/perl6/pugs/trunk/docs/AES/S22draft.pod">S22 draft</a> to collect thoughts on Perl 6's module support and 6PAN issues. Sadly, during the lunch break, I suffered through serious carsick, and cannot resume the session with kane. My apologies.<nobr> <wbr></nobr>:-/</li> <li>Stevan polished the <a href="http://svn.perl.org/perl6/pugs/trunk/perl5/Perl6-ObjectSpace/lib/Perl6/MetaModel/Bootstrap.pm">MetaModel bootstrap</a> sequence to a point that the call graph is looking like S-expressions, so he went ahead and converted them into that. Now we just need a codegen to Perl6/Hs/PIR to finish the bootstrap of the metamodel part -- nothingmuch mentioned the codegen maybe written in attribute grammars (AGs), and that sounds like a good idea.</li> </ul><p> By the way, the main Pugs subversion is again down for the weekends, so try <a href="http://svn.perl.org/perl6/pugs/trunk/">this fallback</a> for latest version. </p><p> That's it for now, I think... More hacking awaits me.<nobr> <wbr></nobr>:)</p> autrijus 2005-11-04T23:51:15+00:00 perl6 Day 243: Fifth day at Liz's: More S17, Bootstrap, Overview. http://use.perl.org/~autrijus/journal/27419?from=rss Tonight Liz and I specified a very strange but powerful <code>alarm()</code> construct in <a href="http://svn.openfoundry.org/pugs/docs/AES/S17draft.pod">S17 draft</a>, and cleared up S17 a bit in general. <p> Among the runtimes, probably only the Haskell one can implement them in full at this moment, although the others can simulate the behaviour using lightweight multiplexing. </p><p> I learned that Parrot's threading code (and design) are currently missing... So after Chip is done with the lexical pads, I'd like to work with him and Leo a bit, to make sure that we are on the same page at grokking the STM+Continuation model. Come to think about it, maybe Dan will suddenly decide to publish Cola's subversion repository and come up with some related stuff as well... </p><p> Stevan started working on the <a href="http://svn.openfoundry.org/pugs/perl5/Perl6-ObjectSpace/lib/Perl6/MetaModel/Bootstrap.pm">MetaModel Bootstrapping sequence</a>, a shared call graph on runtime-provided kernel objects that will establish the Perl 6 object model. The good thing is that it is agnostic to runtimes -- I need only to implement the small amount of underlying intrinsics in Haskell, then we can get a object model for free. This approach is taken from PyPy, with some influence from Ruby/YARV as well. Hurray for symbiotic evolution!<nobr> <wbr></nobr>:-) </p><p> I checked in some fix to Parrot's <a href="http://svn.perl.org/parrot/trunk/docs/overview.pod">overview.pod</a>, removing a paragraph that has bothered me for a long time. Originally, it claimed that Parrot can make use of the vast amount of research literature on compiling to hardware CPUs, compared to the fewer papers on compiling to stack machines. The reality however is that most hardware papers doesn't apply to the infinite-register Parrot, and there just are not many papers on Itaniums (which resembles Parrot the most), compared to the huge amount of JVM and CLR papers. </p><p> I changed it to say that in non-JIT settings, register machines takes fewer operations to perform typical high-level language tasks, and the new scheme of "lexicals are just registers" extends this benefit to intermediate values held in variables as well. Now I feel much happier. For more detail, see <a href="http://citeseer.ist.psu.edu/rd/62574876%2C681798%2C1%2C0.25%2CDownload/http://citeseer.ist.psu.edu/cache/papers/cs/31239/http:zSzzSzwww.complang.tuwien.ac.atzSzantonzSzivme03zSzproceedingszSzdavis.pdf/davis02case.pdf">this paper</a> referred from Jonathan. </p><p> Liz notices that in our Perl 5 embedding examples, we always start with <code>use perl5:DBI;</code>, which is a pretty good indication of the number one module to port over from Perl 5. It turns out that the guts of DBI::PurePerl and stub DBDs are just a few hundred lines, and dduncan volunteered to take a look to port it over to Perl 6, possibly even with a port of DBD::mysqlPP using Pugs's existing sockets support. Woot! </p><p> That's it for today, I think. See you tomorrow!</p> autrijus 2005-11-02T23:25:51+00:00 perl6 Day 242: Fourth day at Liz's - Amsterdam.pm meeting. http://use.perl.org/~autrijus/journal/27416?from=rss (Gasp, pressed "Preview" last night and didn't hit "Submit"...) <p> Full journal instead of stubs tonight, as I'm in the car driving back to Echt, which gives me about two hours of journaling time. </p><p> This afternoon, after sketching out the PA02 draft with Wendy, we drove to Amsterdam for the Perl Monger's meeting. I could't do coding in the car, so I fell back t oreading PickAxe instead, finally finishing it (except the huge library reference parts) at the pre-meeting dinner at a nice Chinese restaurant. </p><p> I like the PickAxe book a lot. Its explanation of EigenClasses ("that <em>something</em>", in Matz's words) and MetaModel was excellent, and the ObjectSpace introspection API made a lot of sense too. However, the constant beating of the "better than Java" dead horse can get a bit tiring at times.<nobr> <wbr></nobr>:-) </p><p> Ruby's lack of container types also means it doesn't have the related set of Perlish ergonomic memes -- eg. sigils, autorefs, contexts, ties, inference, guards -- though that also makes it easier to reason about. However, seeing that Perl 6's dynamic semantics is basically "Ruby++", there's probably nothing precluding a Ruby frontend to Pugs/PIL. On the other hand, it may be easier to write a YARV-&gt;PIR translator. </p><p> The talks were reasonably successful, except I went massively overtime, finishing at almost midnight so people had to run to catch the last trains. Fortunately, by following suggestions from Wendy and Liz about slowing down the pace, the talk apparently worked better; the audience is visibly more receptive than it was at EuroOSCON. I still need to slow down a bit more, leave enough pause time for jokes, and cut most of the digressions, but all in all things seem to be improving. </p><p> The Pugs talk was received most warmly, so much so that I said I'd like to get a list of attendees and send a committer bit invitation to all of them. In particular, people seem to really like the idea of turning <code>use pugs;</code> into a CPAN module, that translates your inline Perl 6 code into Perl 5, preserving the original P6 code (but hide them from the Perl 5 parser), and insert the compiled Perl 5 code, with a SHA digest so those parts can be recompiled when the Perl 6 code changes. This technique resembles Acme::Bleach, Inline.pm and Inline::File, and has the effect of letting people write Perl 6 code that can be uploaded to CPAN to be used as pure-perl5 modules. </p><p> After the talk, Jouke asked whether Ponie will still be relevant, with Pugs targetting Perl 5 and Parrot simultaneously. The answer is a future-tense <em>yes</em>: the first generation of Perl 6 programs are going to be written with <code>use perl5:DBI;</code> in them, so they will run just fine when compiled to Perl 5. However, when Parrot proves to be a more reliable and efficient runtime for Perl 6, we will then want to compile those Perl 6 programs to Parrot. For Parrot to support <code>use perl5:DBI</code>, Ponie is absolutely neccessary. However, until we make the Perl5 and Parrot targetting robust enough, there would be little practical motivation to hack on Ponie, </p><p> Jouke also kindly offered his place to host me in my Erdosing next year; I'd like to work out declarative bindings that work both as GUIs and dynamic websites using the same piece of code, and Jouke's experience with OLE and WxWidgets would be helpful there. </p><p> The "Visual Basic Rocketh" talk was controversial as ever. It does feel strange to play advocate for a language with no free implementations, but I think the two main messages -- <em>evolve or die</em> and <em>shared runtimes are good</em> -- was received reasonably well, so I'm still glad I did the talk. I was also quite surprised that someone in the audience recognized the photo of Erik Meijer... </p><p> It was past 10am at that point, so I asked whether the mongers really want to hear the 45min "Learning Haskell" talk. Most people concurred, but I then made the mistake of going through every slides in my careful-explanation mode, so it took well over an hour. In retrospect, I should have dropped the nitty-gritty detail of technology demonstrations, and focus on getting the bare basics across instead. </p><p> Still, many interesting feedback ensued: Abigail caught a potential infinite loop bug in the partition-based qsort example, and I saw an "Aha" look on several people's face when I explained that <code>print $ f x</code> is the same as <code>print (f x)</code>. I could also have went further and show that <code>print . f $ g x</code> is the same as <code>print (f (g x))</code>, but function composition would probably make the overtime even worse. The overall feeling is that this talk really should be turned into a 3-hour tutorial and splitted into two parts. </p><p> So, a very interesting (if a bit long) day, and a lot of fun. See you tomorrow!</p> autrijus 2005-11-02T13:38:09+00:00 perl6 Day 241: Third day at Liz's - Sketch, PA02, Param syntax http://use.perl.org/~autrijus/journal/27397?from=rss <a href="http://use.perl.org/~jesse/journal/">#parrotsketch meeting</a> last night was a success: <ul> <li>leo++ for finishing the variable-sized register frames</li> <li>pmichaud++ for getting shift/reduce parser to parse rules itself</li> <li>allison++ for announcing the availability of <a href="http://use.perl.org/~Allison/journal/27394">tree transformations</a> (aka Attribute Grammar) and linking to <a href="http://svn.lohutok.net/nam/trunk/parrot/docs/compiler_tools.pod">compiler tools</a> document. I love the upfront declaration of <em>Rule number one: writing compilers is not hard.</em>, but would like to amend it with<nobr> <wbr></nobr><em>...with the right tools</em>. Read the comptools documents for the set of Right Tools coming to Parrot.</li> </ul><p> Liz and I keep finding serializable continuations very useful for S17, especially for intospection and development purposes (imagine "stepping back" in your debugger). It seems that the next <a href="http://agylen.com/2005/06/12/mozilla-rhino-to-be-included-in-j2se-60/">JVM</a> release may support Rhino-style serializable continuation, which would make it a first-class perl6 target. </p><p> Lots of nice feedback on S17. Still need to tackle coro, junctions and hyperops in the face of multiple core CPUs. </p><p> Stevan started populating <a href="http://svn.openfoundry.org/pugs/perl5/Perl6-ObjectSpace/">Perl6-ObjectSpace</a> with Real Code (tm). </p><p> iblech fixed Pugs parser and internals to deal with the syntax change in the new <a href="http://svn.perl.org/perl6/doc/trunk/design/syn/S06.pod">S06</a>. The <a href="http://rt.openfoundry.org/Foundry/Project/Source/index.html/pugs/revision/?rev=7792">commit log</a> provides a succint summary. </p><p> Looking forward to tomorrow's Amsterdam.pm meeting. </p><p> Note to self: fix the bug reported by xinming: <code> class a { has $.a; method update { $.a; } };class b { has $.a; submethod BUILD { a.new( a =&gt; $.a ).update; }; }; b.new( a =&gt; 20 );</code> </p><p> Wendy and I started annotating the <a href="http://pugscode.org/images/simple-compilation.png">illustrations</a> with simple question/answer notes, captured in the rough sketch that will hopefully become an accessible <a href="http://svn.openfoundry.org/pugs/docs/02Architecture.pod">PA02: Architecture</a>. Pugs has long suffered from the steep initial learning curve; the Apocrypha series was planned to remedy that, but somehow I lost the perspective of explaining things in a concise fashion. To that end, the ObjSpace coding was delayed for a day, but I think it's worthwhile to apply the same Q/A treatment for PIL, Object Space, MetaModel and the rest of Pugs jargons. Feedback welcome! </p><p> Now I'm off to Amsterdam.pm meeting, which means lots of communication and less coding for today. Wish me luck!</p> autrijus 2005-10-31T22:20:40+00:00 perl6 Day 240: Second day at Liz's - ObjSpace, S17 http://use.perl.org/~autrijus/journal/27375?from=rss <p> Yesterday and this morning was a lot of fun, and also very productive. </p><p> I had a SubEthaEdit+Skype session with Stevan; we worked out a sketch of the <a href="http://svn.openfoundry.org/pugs/docs/notes/object_space.txt">Object Space</a> and primitive operations that supports them. Back when the focus at 6.2.x was about flow control semantics, I designed PIL with Chip and Leo to simplify the possible semantics Perl 6 can take. Now for 6.28.x, the ObjSpace and PrimOps are the logical counterpart for the OO part of the language. We learned whatever we can from Python's <a href="http://codespeak.net/pypy/dist/pypy/doc/news.html">PyPy</a> and Ruby's <a href="http://www.atdot.net/yarv/insnstbl.html">YARV</a> (cf. <a href="http://www.atdot.net/yc/compile">Online Compiler</a>), as the goal is identical to theirs -- have a shared minimal interface that all runtimes ought to provide, to support a consistent, fast and portable metamodel on top of it. </p><p> I also worked with Liz in two design sessions, which produced some rough notes of <a href="http://svn.openfoundry.org/pugs/docs/AES/S17draft.pod">S17: Concurrency</a>. Many of Liz's <a href="http://search.cpan.org/~elizabeth/">Threads::*</a> modules on CPAN are workarounds for Perl 5's <em>principle of most surprise</em> ithread model, and we spent much time making sure that those won't happen under Perl 6 semantics. </p><p> Aside from that, we played with the idea of <code>is atomic</code>, <code>is critical</code> and <code>is throttled</code> traits on Code objects, and they seem to capture many key abstractions found in everyday concurrency programs. The idea of providing an unified interface to multiple concurrency models -- lightweight multiplex, OS threads, and process forks -- is also alluring, so we toyed with more bizzare ideas like having <code>$thread.detach</code> promote the thread into a process so it can survive its parent's demise. </p><p> The feedback to both texts were so far very positive, although we really need to elaborate the text more. A new set of Visiolization diagrams won't hurt either, as it's about time to update the <a href="http://cafepress.com/pugscode/">Cafepress</a> merchandise designs. </p><p> Apart from Liz's amazing sense of "Right Thing"ness, Wendy has also been helpful during the design process; not suffering from overexposure to perl5 workarounds and perl6 mindset, she provides the much needed real-time usability feedback. I think I'll need to do a Type System design session with her soon, as a sanity-check for the "incremental staticness" idea of Perl6's -- it is rare that I meet someone with a higher internal clock speed and raw mental capacity compared to mine.<nobr> <wbr></nobr>:) </p><p> Last night eric256 extended the test matrix concept with a wonderfully informative <a href="http://feather.perl6.nl/~eric256/t_index/">Test Catalog</a> that visualizes the link between tests, synopses, and smoke results. </p><p> Also, reading PickAxe and PyPy documentations makes me rethink if Perl 6 is really dynamic enough. For example, would defining <code>&amp;postcircumfix:&lt;( )&gt;</code> for Hash classes do what <code>__apply__</code> does for Python, namely having arbitrary hash serve as closures? Definitely p6l stuff, although I'll probably run those random thoughts off #perl6 before posting them. </p><p> Today I'm going to focus on coding up the lower layers of the object space, and see how much bootstrapping I can do with those bare primitives. It should be fun. Wish me luck!</p> autrijus 2005-10-31T00:48:26+00:00 perl6 Day 239: Hacking Starts. http://use.perl.org/~autrijus/journal/27369?from=rss I arrived safely at <a href="http://liz.nl/">Liz</a> and <a href="http://wendy.org/">Wendy</a>'s place, a lovely house in Echt, Netherlands. In the next 9 days, I'll be hacking nonstop on Pugs, before flying to Helsinki and finally back to Taiwan. <p> The primary goal is to get the object space and metamodel figured out and integrated to the base runtime for 6.28.0. Stevan mentioned he will have some spare time to gobby/subethaedit with me; I'm looking forward to it. </p><p> Also, because Liz is known as the Queen of Threads of Perl, obra asked me to work out the currently unspecced <a href="http://svn.perl.org/perl6/doc/trunk/design/syn/S17.pod">Synopsis 17</a> with her. As @Larry's forte is on language ergonomics, it makes a lot of sense to hand off the more specialized part to domain experts.<nobr> <wbr></nobr>:-) </p><p> To avoid the too-tired-to-journal-anymore problem, I'm switching to journal every day before hacking, instead of after it. Sorry for the lapse in the past few days; part of it was due to traveling, but also because <a href="http://phrogz.net/ProgrammingRuby/">Programming Ruby</a> (deadtree edition) is much too enjoyable. Larry evidently took lots of good ideas from Matz, and grokking Ruby makes it much easier to see the power behind the dynamic, runtime-typed part of Perl 6. </p><p> I read that Matz <a href="http://jroller.com/page/obie?entry=matz_roundtable_notes">suggests</a> at the RubyConf roundtable that <a href="http://www.iolanguage.com/about/">io</a> and <a href="http://haskell.org/">Haskell</a> are the two language most worthy to learn at this moment. Indeed, I like io a lot -- it has a "JavaScript distilled" feeling -- but I plan to hold off writing something in it after this current Hackathon. </p><p> Speaking of JavaScript, Bredan <a href="http://weblogs.mozillazine.org/roadmap/archives/009177.html">blogged</a> about our short encounter in Tallinn. It is entirely possible that the JavaScript backend may prove to be the most important one, especially if <a href="http://www.mozilla.org/js/spidermonkey/">SpiderMonkey</a> do get first-class continuation support from <a href="http://www.mozilla.org/rhino/">Rhino</a>, as Bredan had suggested, which will make performance and memory use much more practical. (Indeed, if JavaScript2 does survive the standardization process, it is entirely possible that it may become the next Ruby, because writing programs that runs at both client and server side is a strong motivation -- the same reason to keep Pugs targetable to multiple backends.) </p><p> The Copehagen.pm meeting was a lot of fun. I chatted with Anton about putting a tag-based search interface, akin to <a href="http://debtags.alioth.debian.org/">DebTags</a>, for CPAN and/or FreeBSD ports; he started prototyping that night, producing a set of tags summarized from package descriptions -- we'll see if this idea plays out or not. </p><p> Back at NPW, sky had this great idea of using something akin to <a href="http://search.cpan.org/dist/B-Generate/">B::Generate</a> -- but written in C/Haskell -- to speed up the currently very slow Perl5 backend, by generating optimized OP trees directly from Perl6/PIL tree, without going through the Perl 5 source level again. This may raise Perl5 into a production-worthy runtime of Perl6 code, which would be a Very Good thing. It is also conceivable to hack more Perl6-support OP codes into Perl5, either via dynamically-loaded XS runtime augmentation, or by hacking them into Perl 5.10 itself. More details later... </p><p> Okay, enough words. Time to code. See ya!<nobr> <wbr></nobr>:)</p> autrijus 2005-10-30T12:32:40+00:00 perl6 Day 234: More travelling... http://use.perl.org/~autrijus/journal/27309?from=rss NPW was wonderful; I <a href="http://flickr.com/photos/jooon/55661134/">smiled</a> a lot, had a wonderful time, and also discussed quite a bit about multiversioning and possible <a href="http://perlcabal.org/~autrijus/6pan.txt">6pan</a> topics. <p> In 3 hours I'll be travelling to Copenhagen, stay there for a few days and meet <a href="http://copenhagen.pm.org/">cph.pm</a> folks, then to Brussels on this weekend. </p><p> The <a href="svn.openfoundry.org/pugs/docs/quickref/fears">fears</a> project, a self-administered group therapy initiated by Juerd, is absolutely wonderful. </p><p> I'm halfway through the PickAxe book, and also immersing myself on PyPy notes; expect more massive sync/push when I get somewhat more stable network connection. See ya!</p> autrijus 2005-10-25T16:41:01+00:00 perl6 Day 230: In Stockholm. http://use.perl.org/~autrijus/journal/27273?from=rss Again, lots of travel (this time for the <a href="http://www.perlworkshop.dk/2005/">NPW</a> tomorrow), including sorting out a misbooking from hotels.com, so didn't get much done on the road. <p> Last night I got a most amazing Black Camel award from Amsterdam.pm, with shining hues and a beautiful shape. Also got some work done with Larry on Tuple syntax for Perl6. </p><p> On the plane from Amsterdam to Stockholm, kane synced with me about his ideas of 6PAN, mostly centered around multiversioning, dist-time metadata, dpkg-based installation info, as well as policy files for resolving multiple versions and sources of the same module. All in all very fruitful -- details later. </p><p> There's a social meeting for early arrivers at Bagpiper's Inn, but sadly I'm probably going to miss it and sleep. See you tomorrow...</p> autrijus 2005-10-21T18:24:26+00:00 perl6 Day 229: Learning Haskell. http://use.perl.org/~autrijus/journal/27256?from=rss My last talk in Euro OSCON just went live. Despite being rushed to completion at the last minute as usual, it's received surprisingly well. <p> The <a href="http://pugscode.org/talks/euroscon05/haskell.xul">slides</a> are available online; all are linked from <a href="http://pugscode.org/">pugscode.org</a> as well. </p><p> Suggestion welcome -- I'm going to present all four of them again in the coming week at Nordic Perl Workshop, and probably again in OSDC Australia, so there are plenty of chances of tuning.</p> autrijus 2005-10-20T13:29:44+00:00 perl6 Day 227: Three talks down, one to go! http://use.perl.org/~autrijus/journal/27233?from=rss Today's three talks all went really well, though all of them were finished ~5mins before the actual talk began. In the order of presentation, they are: <ul> <li> <a href="http://pugscode.org/talks/euroscon05/vb.xul">Visual Basic Rocketh!</a> (favourite slide: <a href="http://pugscode.org/talks/euroscon05/vb.xul?page=59">Evolve or die;</a>)</li> <li> <a href="http://pugscode.org/talks/euroscon05/mariner.xul">Larry was a mariner...</a> (favourite slide: <a href="http://pugscode.org/talks/euroscon05/mariner1.xul?page=13">Perl6 chimera</a>)</li> <li> <a href="http://pugscode.org/talks/euroscon05/pugs.xul">Introduction to Pugs</a> (favourite slide: <a href="http://pugscode.org/talks/euroscon05/pugs1.xul">Best practice</a>)</li> </ul><p> Got many people signed up for committer bits -- dconway (who'd like to hack the mariner poem before I present it with him in <a href="http://osdc.com.au/">OSDC</a>), sky, liz, schuyler, among other very cool folks. Woot! </p><p> So I get to enjoy the first restful sleep in many nights. Of course, there is still <a href="http://pugscode.org/talks/euroscon05/haskell.xul">one unfinished talk</a> to go -- people are expecting it to be a <em>instant Pugs hacking boot course</em> for Haskell, which is kinda hard to do in 45 minutes -- though I'll manage somehow. See you!</p> autrijus 2005-10-18T21:54:34+00:00 perl6 Day 225: Demagicalized pairs! http://use.perl.org/~autrijus/journal/27195?from=rss I didn't get to do much slide hacking, as the lack of sleep on the ferry and airplanes are kicking in, but what I have so far is at <a href="http://perlcabal.org/~autrijus/tmp/pugs.xul">Pugs.xul</a>. You'll notice that I am in serious Unicode-abuse mode... <p> scook0 valiantly demagicalized pairs. This means <code>foo($thing)</code> now always pass <code>$thing</code> positionally to <code>&amp;foo</code>, even if <code>$thing</code> happens to be a <code>Pair</code>. </p><p> On the flip side, <code>foo(bar =&gt; $baz)</code> now always passes <code>$baz</code> by the name <code>bar</code>, even if <code>&amp;foo</code> expects <code>Pair</code>s. Hurray for sanity! </p><p> For some context behind this pair-magic situation, consult the thread "Demagicalizing pair" on p6l <a href="http://article.gmane.org/gmane.comp.lang.perl.perl6.language/4778">started</a> by luqui, <a href="http://colabti.de/irclogger/irclogger_log/perl6?date=2005-10-09,Sun&amp;sel=528#l830">#perl6's consensus-building discussion</a>, and <a href="http://www.nntp.perl.org/group/perl.perl6.language/23532">Larry's rulings</a>. </p><p> iblech then proceeded to update PIL2JS accordingly, which means that PIL2JS is the first backend which fully supports demagicalized pairs -- it passes all of the 26 tests of <code>t/syntax/pairs.t</code>. </p><p> Stevan hacked in a minimal parser for Perl6-style class declaration for the Perl5 metamodel, to test out the eventual integration with PIL2. We bounced a couple ideas at #perl6 about serializing compile-time class objects, but sleep deprivation starts kicking in. As putter so wisely put, one probably should not get burnt out at the <em>beginning</em> of a conference, so I'll catch some sleep now. See ya!<nobr> <wbr></nobr>:)</p> autrijus 2005-10-16T19:32:33+00:00 perl6 Day 223/224: In transit. http://use.perl.org/~autrijus/journal/27189?from=rss I'm currently in Stockholm airport, about to board the flight to Amsterdam. Apparently, while I was aboard the Viking ferry to Stockholm, my mailbox got full, openfoundry.org got its weekend shutdown, and technorati got horribly spammed. Ew. <p> However, I did manage to get more than half of presentations done, and plan to pound on the rest of them tonight. I'll bbiab...</p> autrijus 2005-10-16T10:04:56+00:00 perl6 Day 222: More Takahashing. http://use.perl.org/~autrijus/journal/27161?from=rss Another day of Javascript hacking to get the slides Just Right, while trying not to go overboard and rewrite Spork in JS. Just like Ruby is touted as the new Perl, I think evidently Javascript is the new Ruby -- after all, it has <em>only</em> eigenclasses and nothing else...<nobr> <wbr></nobr>;-) <p> As it happens, I split the Learning Haskell talk into separate sections: <a href="http://perlcabal.org/~autrijus/tmp/haskell.xul">Overview</a>, <a href="http://perlcabal.org/~autrijus/tmp/haskell1.xul">WTF?</a>, <a href="http://perlcabal.org/~autrijus/tmp/haskell2.xul">Types</a>, <a href="http://perlcabal.org/~autrijus/tmp/haskell3.xul">Functions</a>, <a href="http://perlcabal.org/~autrijus/tmp/haskell4.xul">Techs</a> (in progress), as well as the not-yet-started <a href="http://perlcabal.org/~autrijus/tmp/haskell5.xul">More!</a> . </p><p> Suggestions welcome... I'm going to do some more slidehacking now.<nobr> <wbr></nobr>:) </p><p> By the way, chip++ for coming to #perl6 to discuss how Parrot should provide efficient lexical pads, OUTER:: and CALLER:: access, and related issues like the BEGIN blocks. It's really nice to resume that continuation from Vienna!</p> autrijus 2005-10-14T01:12:20+00:00 perl6 Day 221: Wordsmithing. http://use.perl.org/~autrijus/journal/27143?from=rss Today was all about hacking in the English language. I started working on the <em>Learning Haskell</em> talk, but ended up getting less than half finished, partly due to hacking the amazing <a href="http://piro.sakura.ne.jp/xul/applications/takahashi/">Takahashi XUL kit</a> and converting the CUFP Pugs talk into that format. <p> You can take a look at my <a href="http://perlcabal.org/~autrijus/tmp/haskell.xul">work in progress</a>; note that the code snippets are not in preformatted layouts as they should be. But try to "view source" and move the mouse cursor on top of the canvas -- you'll be positively surprised. </p><p> 45 minutes is not anywhere enough to get people acquainted with <em>both</em> Haskell's syntax and practical uses, so the slides are very concise. Suggestions welcome! </p><p> On the lightning talk front, I collaborated with Allison over <a href="http://www.codingmonkeys.de/subethaedit/">SubEthaEdit</a>, as the <a href="http://gobby.0x539.de/">Gobby</a> site still does not offer a OSX binary package. We adapted the first two stanzas, reviewed another four, and left the remaining six untouched. The text is in the pugs tree as <a href="http://svn.openfoundry.org/pugs/docs/talks/larry_mariner.txt">docs/talks/larry_mariner.txt</a>. Making an epic-esque poem of Perl is quite challenging; it would be impossible without Allison's strong poetic cluefulness. But we still need much help from fellow wordsmiths... </p><p> After Euro OSCON, I'll be in Stockholm for <a href="http://conferences.yapceurope.org/npw2005/">Nordic Perl Workshop</a>. A month after that, I'll be in Australia for <a href="http://www.osdc.com.au/">OSDC 2005</a>, hopefully finding some time to work with Damian, as well as visiting <a href="http://www.cse.unsw.edu.au/~dons/">dons</a> (of hs-plugins/yi fame) in Sydney. </p><p> Hmm, it's well past 5am, so no changelogging for today... See you tomorrow!</p> autrijus 2005-10-13T02:20:29+00:00 perl6 Day 221 (r7568): A day of reading. http://use.perl.org/~autrijus/journal/27122?from=rss Happily, both lightning talks got accepted, so I committed the unadapted <a href="http://svn.openfoundry.org/pugs/docs/talks/larry_mariner.txt">Larry was a mariner</a> text into the Pugs tree, planning to work on it (and read <a href="http://www.amazon.com/gp/product/1593600259/002-1756408-9829609">The Sillymarillion</a>) whenever my brain feels overheated. Thoughts, ideas, patches and commits are all very much welcome! <p> Today I wade through the code in <a href="http://svn.openfoundry.org/pugs/perl5/">perl5/</a> (i.e., the Perl5 and JS runtime engines), to prepare for the renovated container/object runcore. The Perl5 runtime's hook with metamodel was very enlightening, and fglock's meticulous TODO comments helped much. Also iblech's <a href="http://svn.openfoundry.org/pugs/perl5/PIL2JS/libjs/PIL2JS.js">JS runtime</a> is so concise, it looks almost like poetry. *smile* </p><p> I then turned to read <a href="http://svn.openfoundry.org/pugs/docs/notes/theory.pod">theory.pod</a> for the third time, which is a good summary of GADTs and generics in a Perl6 setting -- but whenever I start to think about how to reconcile it with optional dynamicness, my head starts throbbing. No wonder why Larry spent much time <a href="http://www.nntp.perl.org/group/perl.perl6.language/23429">mulling over</a> it, and I sympathize luqui's <a href="http://use.perl.org/~luqui/journal/27116">conflicted feeling</a> a lot. Still, I think here formalization still helps, not hinders, so I look forward to spend some time with @Larry next week to hammer this out. </p><p> On the metamodel front, stevan attempted to steer Perl6's OO model toward Smalltalk/CLOS/Ruby from the Java/C++ direction, <a href="http://www.nntp.perl.org/group/perl.perl6.language/23455">proposing</a> that we drop class method inheritance and instead embrace eigenclasses, per-instance methods and roles as the True Way of doing things. Damian <a href="http://www.nntp.perl.org/group/perl.perl6.language/23456">wondered</a> how can we tell people to do away with the perl5 idiom of inheritable class-method <code>new</code>, and the discussion continues... Personally I think having a certain kind of Class that supports inheritable class methods can work out, but I'm not sure; fortunately, stevan volunterred to experiment and report back. </p><p> eric256 continued to make examples more pugs and runnable, and uncovered a bug that makes pugs too eagerly handle <code>-n</code> and <code>-p</code> in the script's argument list. </p><p> iblech added proper exception for division/modulo-by-zero to PIL2JS, a complete set of bit operators, fixed evaluation order so the indices are evaluated before the array/hash, and converted more p6l discussions into somewhat saner and certainly more tractable tests. </p><p> There's more, but I need to sleep. Ciao!<nobr> <wbr></nobr>:)</p> autrijus 2005-10-12T00:55:10+00:00 perl6 Day 220 (r7546): Gearing up for Euro OSCON. http://use.perl.org/~autrijus/journal/27101?from=rss With the release done, life resumed back to a less frantic pace but still with much fun. Yesterday's <a href="http://developers.slashdot.org/article.pl?sid=05/10/09/1831219">slashdotting</a> was amusing and nice -- although chromatic regretted using the cute phrase "frivolous toy interpreter" to describe Pugs, overall it has resulted in more interest and reasonable discussions. <p> The only thing I did totally wrong was redirecting the then-unreachable autrijus.org to my <a href="http://en.wikipedia.org/wiki/Autrijus_Tang">Wikipedia Page</a> before I slept; immediate vandalism ensued to change my photo into goatse, and it stayed up there for six hours. Ow!<nobr> <wbr></nobr>:-/ </p><p> Today's <a href="http://www.parrotcode.org/misc/parrotsketch-logs/irclog.parrotsketch-200510/irclog.parrotsketch.20051010">#parrotsketch meeting</a> went well. obra adopted a new trick of asking each participant what is blocking them, and it triggered a sudden flow of constructive discussion; I hope this format continues for the weeks to come. </p><p> I asked on the sketch for ideas of the Euro OSCON lightning talks -- because I'm procrastinating on preparing my slides, and having to prepare <em>more slides</em> sounds like a useful distraction -- and obra gave me an idea of presenting <em>alien and advanced language concepts</em>. To that end, I submitted the first lightning talk proposal, <em>"Visual Basic Rocks!"</em>:</p><blockquote><div><p>In the Open Source world, VB has long been held in disdain and contempt. However, ever since the VB team was infiltrated by lambda ninjas, it took a strange turn and introduces some mind-bendingly advanced concepts not found in free dynamic languages. You'll have to <a href="http://msdn.microsoft.com/vbasic/future/default.aspx">see it</a> to believe it!</p></div> </blockquote><p> Inspired by her <a href="http://www.lohutok.net/talks/snark_spoof.html">the Hunting of the Perl</a>, I also asked Allison to do a poetry performance together, and she graciously agreed. After some brainstorming, we decided to adapt the Earendil song into <em>"Larry was a mariner"</em>,:</p><blockquote><div><p>In this lightning talk, Allison and Autrijus will perform an adapted version of Tolkien's Song of Earendil, the "title poem" of both Perl5 and Pugs, to celebrate Larry's long and fruitful voyage in the land of Perl.</p></div> </blockquote><p> On the code front, eric256 did a cleanup of the examples/ directory, correcting a few that lapsed due to minor syntax changes, and uncovered a bug: <code>s:g/\s*//</code> would hang indefinitely as our zero-width substitution was not advancing the cursor. I fixed it promptly. </p><p> iblech, in search for the remaining few features that the JavaScript backend does not yet support, implemented<nobr> <wbr></nobr><code>.assuming</code> (which prompted fglock to add it to PIL-Run too), numeric bitwise operators. He also hacked in escape-code-free<nobr> <wbr></nobr><code>.perl</code> support for byte strings, and<nobr> <wbr></nobr><code>.perl</code> for regular expressions. </p><p> rafl worked tirelessly to get the packaing Just Right; with nomeata's help, Pugs 6.2.10 is uploaded to Debian now. Yay! </p><p> Stevan fixed the implementation of eigenclasses a bit, then sanity-checked with me the idea of a parallel eigenclass hierarchy created eagerly for each Class object, in a Smalltalkesque fashion. Fortunately, this eigenclass thing is quite orthogonal to the rest of metamodel, so it shouldn't hinger my move into container and metamodel runcore... </p><p> With leo's help, embedding with Parrot (post-0.3.0 trunk) is fully resumed; among other things, we were missing a <code>Parrot_exit</code> call, so stdout was not flushed. I factored out _GlobalFinalizer, so now all embedded Parrot objects and Perl5 objects will be finalized alongsid Pugs objects upon program termination. </p><p> That's it for today. See you tomorrow!</p> autrijus 2005-10-11T00:39:12+00:00 perl6 Day 219 (r7520): Pugs 6.2.10 released! http://use.perl.org/~autrijus/journal/27089?from=rss I am delighted to announce Pugs 6.2.10, released during a slashdotting on geoffb's "Optimizing for Fun" column:<blockquote><div><p> <a href="http://developers.slashdot.org/article.pl?sid=05/10/09/1831219">http://developers.slashdot.org/article.pl?sid=05/10/09/1831219</a></p></div> </blockquote><p> The release tarball will be available from CPAN shortly:</p><blockquote><div><p> <a href="http://pugscode.org/dist/Perl6-Pugs-6.2.10.tar.gz">http://pugscode.org/dist/Perl6-Pugs-6.2.10.tar.gz</a> <br> SIZE = 2394516<br> SHA1 = 3d8669fdccc3616c99cdde68659759b8b5782859</p></div> </blockquote><p> With two months of development, this release features more tightly integrated JavaScript and Perl5 code generator backends, a library interface to the Pugs system via support for the Haskell Cabal frameworks, as well as many new tests. </p><p> After the release, the push toward 6.28.0 will begin in earnest, with the newly specified container model and object model integrated back to the main runtime, fleshing out support for the remaining OO features. </p><p> Again, thanks to all the lambdacamels for building this new ship with me.<nobr> <wbr></nobr>:) </p><p> Enjoy!<br><nobr> <wbr></nobr>/Autrijus/ </p><p> <b>Changes for 6.2.10 (r7520) - Oct 10, 2005</b> </p><p> <b>Feature Changes</b> </p><p> <em>Shared components</em> </p><ul> <li>Support for the Haskell Cabal framework, exposing Pugs as a library to other Haskell users, paving the way for use in IDEs, as well as future Inline::Pugs and Inline::GHC modules</li><li>Adopted the code convention of expanding literal tab chars to spaces</li><li>JavaScript backend can be invoked with <tt>pugs -B JS</tt> </li><li>Perl 5 backend can be invoked with <tt>pugs -B Perl5</tt> </li><li>Pugs will now compile version ranges in &#39;use/require&#39; statements</li><li>Significant backend enhancements; see below</li><li> <tt>$?PUGS_BACKEND</tt> can be used to tell which runtime is in use </li><li> <tt>exec</tt> emulated &#40;partially&#41; on Win32</li></ul><p> <em>JavaScript backend</em> </p><ul> <li>Passes 91% of the main test suite &#40;including TODO failures&#41;</li><li>Integrated with MetaModel 1.0</li><li>Faster code generation, taking advantage of <tt>-CPerl5</tt> output.</li><li>Switched to continuation passing style &#40;CPS&#41; to properly support <tt>return&#40;&#41;</tt>, <tt>&#38;?CALLER_CONTINUATION</tt>, coroutines, and <tt>sleep&#40;&#41;</tt> </li><li>Improved support for binding and autodereferentiation</li><li>Initial support for multi subs</li><li>Initial support for symbolic dereferentiation</li><li>List construction no longer creates new containers</li><li>Miscellaneous performance improvements</li><li>Named-only arguments &#40;<tt>+$x</tt> and <tt>++$x</tt>&#41; can&#39;t be passed positionally anymore</li><li>Parts of the Prelude can be written in Perl 5 now to improve performance</li><li>Perl 5-like regular expressions mostly working</li><li>Proper UTF-8 handling</li><li>Support for &#34;monkey-but&#34; &#40;<tt>$foo but {...}</tt>&#41;</li><li>Support for <tt>$CALLER::</tt> and <tt>$OUTER::</tt> </li><li>Support for <tt>lazy {...}</tt> blocks for delayed evaluation</li><li>Support for <tt>temp</tt> and <tt>let</tt> declarations</li><li>Support for array and hash autovivification</li><li>Support for array and hash slices</li><li>Support for evaluating expressions in the PIL2JS shell &#40;<tt>:e &lt;exp&gt;</tt>&#41;</li><li>Support for junctions</li><li>Support for loading JSAN modules by using <tt>use jsan:Module.Name</tt> </li><li>Support for lvalue subroutines &#40;<tt>foo&#40;&#41; =<nobr> <wbr></nobr>...</tt>&#41;</li><li>Support for slurpy hashes in subroutine signatures</li><li>Support for the <tt>Proxy</tt> class &#40;not yet user-visible&#41;</li><li>Support for the <tt>eqv</tt> operator</li><li>Using <tt>for</tt> with only one element to loop over works now</li><li> <tt>int&#40;&#41;</tt> works correctly on special values like <tt>Inf</tt> or <tt>NaN</tt> now</li><li> <tt>substr&#40;&#41;</tt> returns a r/w proxy: <tt>substr&#40;$str, $pos, $len&#41; = $replacement&#41;</tt> </li></ul><p> <em>Perl 5 backend</em> </p><ul> <li>Passes 33% of the main test suite &#40;including TODO failures&#41;</li><li>Integrated with the Perl 5 edition of MetaModel 2.0</li><li>Compiles and runs Perl 6 version of <tt>Test.pm</tt> </li><li>Infinite lazy lists, Pairs, References, and intrinsic classes</li><li>Multi Sub, Class, Match, exceptions, types and subtypes</li><li>Scalar, Hash and Array containers, with tieing, binding and read-onlyness</li><li>Support for an extensive list of operators</li><li>Supports eval&#40;&#41; with Perl 5 and Perl 6 code</li><li> <tt>%ENV</tt> is shared with Perl 5; <tt>@INC</tt> is separate from <tt>@Perl5::INC</tt> </li></ul><p> <b>Bug Fixes</b> </p><p> <em>Shared components</em> </p><ul> <li>Fixed <tt>foo {1}.blah</tt> being misparsed as <tt>foo&#40;{1}&#41;.blah</tt> </li><li>Fixed a hashref infinite loop</li><li>Fixed infinite loop on sub { 1 }.pairs</li><li>Multiple <tt>sub foo</tt> no longer silently means <tt>multi foo</tt> </li></ul><p> <em>JavaScript backend</em> </p><ul> <li>Fixed evaluation order of assignments and bindings</li><li>Fixed<nobr> <wbr></nobr><tt>.values</tt> and<nobr> <wbr></nobr><tt>.kv</tt> to return aliases</li></ul><p> <b>Bundled Modules</b> </p><p> <em>New Perl 6 modules</em> </p><ul> <li>Perl6-Container-Array, Perl6-Value-List: prototype modules for implementing Lazy lists in Perl 6.</li><li>Log-Selective</li><li>Cipher - Cipher API suite for cryptographic ciphers</li><li>FA-DFA</li></ul><p> <em>Updated modules</em> </p><ul> <li>Locale-KeyedText: Synchronized with p5 version 1.6.2</li><li>Test-Builder: new APIs, including test_pass&#40;&#41; and test_fail&#40;&#41;</li></ul><p> <em>Experimental modules (in misc/, not installed)</em> </p><ul> <li>Blondie, prototype compiler for native code generation and type-inferencing with Attribute Grammers </li><li>XML::SAX</li><li>Getopt::Long</li><li>Rosetta-Incubator, a complete set of Rosetta[|::<strong>] and SQL::Routine[|::</strong>] modules, restarted development at 2005.09.29</li></ul><p> <b>Test, Examples and Documentations</b> </p><ul> <li>Many new tests and test refactoring, we now have 10300+ tests</li><li>Documentation for draft GC API at <tt>docs/notes/GC.pod</tt> </li><li>Data file for curcular prelude exploratory diagram at <tt>docs/notes/compilation_of_circular_prelude.graffle</tt>, some examples at <tt>docs/notes/circular_prelude_stuff.pl</tt> </li><li>Collaborative journal at<nobr> <wbr></nobr><tt>/docs/journal</tt> </li><li>Autrijus&#39;s CUFP talk at<nobr> <wbr></nobr><tt>/mirror/pugs/docs/talks/cufp2005.txt</tt> </li><li>Theory Model proposal at <tt>docs/notes/theory.pod</tt> </li></ul> autrijus 2005-10-10T01:14:01+00:00 perl6 Day 218 (r7453): Night before 6.2.10. http://use.perl.org/~autrijus/journal/27084?from=rss ...and I foolishly thought Cabalization was the only thing left for the release. Silly me.<nobr> <wbr></nobr>:-) <p> So, the main test suite is passing 100% now, and only one small OO bug remains in the extension tests. That's the good news. </p><p> The not-so-good news is that Cabalization triggered uncovered a bunch of issues previously swept over the carpet: where to install pugs-specific files, where to install modules that are useful for any perl6 implementation, and how the directory structure interact with Debian, FreeBSD, Win32, and various other hierarchy systems. </p><p> In addition to this, there were various issues around GHC 6.4/6.4.1, Cabal 1.0/1.1.4, embedding Perl5 (shared/static), embedding Parrot (0.3.0/trunk). Thanks to patient and helpful feedback from #perl6, I think we figured out solutions to all of them -- hmm, famous last words.<nobr> <wbr></nobr>;-) </p><p> All in all, I'd like to thank rafl, iblech, gaal, scook0, geoffb, vkon, xinming -- among many others I'm sure I missed -- for ironing out this complex interactions between build systems so readily and thoroughly, and I hope tomorrow's release will prove our effort worthwhile. See you!</p> autrijus 2005-10-09T00:18:46+00:00 perl6 Day 216 (r7372): Pugs, Cabalized! http://use.perl.org/~autrijus/journal/27052?from=rss No, this Cabal is not @Larry, but rather the <a href="http://haskell.org/cabal/">Haskell Cabal</a>, the equivalent of Module::Build. After lots of overtime hacking today, Pugs is finally built using cabal, thus exposing Pugs as a library to other Haskell users:<blockquote><div><p> <tt>import Pugs<br>main = doRun "-" [] "say 'Hello, World!'"</tt></p></div> </blockquote><p> Aside from the obvious application to hIDE and other script-haskell-with-perl6 uses, this also makes Inline::Pugs and Inline::GHC much nearer in sight, which is a Good News for people who'd like to mix perl6 code with perl5. Of course, it can't replace the seamlessness of the Pugs/Perl5 runtime, but TIMTOWTDI. </p><p> #perl6 is unusually lively today under the <b>-O<em>pun</em> </b> (optimize for pun) banner; again, I blame <a href="http://redhanded.hobix.com/">Why</a>. And yes, I'm quite aware that we are the only bunch of people who use <em>EigenClass</em> seriously, but it fits in right alongside names such as <a href="http://svn.openfoundry.org/pugs/perl5/Perl6-MetaModel/lib/Perl6/MetaModel/">Psyche, Pneuma and Chaos</a>. Parodies do find a way into real life... </p><p> Prompted by his righteousness as a debian packager, rafl undertook the massive job of reorganizing the modules/ and perl5/ directory into the installable (and eventually CPANable) perl5/, and the for-your-information-only misc/. Hurray! </p><p> gaal finished triaging the failing tests, eliminating the t/ ones, so we only have some 100 of ext/ ones to worry about tomorrow. There are a bunch of other developments today, but I can't keep up anymore. See you after a much deserved sleep.<nobr> <wbr></nobr>:)</p> autrijus 2005-10-07T02:59:09+00:00 perl6 Day 215 (r7327): -Ofun: The most important optimization. http://use.perl.org/~autrijus/journal/27035?from=rss geoffb fulfilled his promise and delivered a nice <a href="http://www.oreillynet.com/pub/wlg/7996">write-up</a> of yesterday's #perl6 discussion. The immediate reaction:<blockquote><div><p> <tt> &lt;autrijus&gt; geoffb: I feel... a bit embarrased I guess, but very grateful for the writeup. it's excellent.<br> &lt;geoffb&gt; thanks<br> &lt;autrijus&gt; geoffb++<br> &lt;geoffb&gt; I had a choice to make you anonymous or not, I decided that people just plain like celebrities.<nobr> <wbr></nobr>:-)<br> &lt;leo__&gt; geoffb++<br> &lt;geoffb&gt; thanks for the kind words<br> &lt;autrijus&gt; geoffb: hence, the embarrasment </tt></p></div> </blockquote><p> It is an excellent summary. However, I'd like to stress that <em>none</em> of those are designed upfront; indeed, I didn't set out to do anything more than modelling junctions. As geoffb said, everything else were spotaneously derived from optimizing for fun. </p><p> In other weblog news, why the lucky stiff <a href="http://redhanded.hobix.com/inspect/pugsAndEigenclassesYessirThisSatireSGotLegs.html">immediately noticed</a> that we did, in fact, steal the <em>eigenclasses</em> -- which is I suspect that he was aiming for all along, with all those hypnotising <a href="http://redhanded.hobix.com/cult/theLeastSurprised2CodingAtVanishingPoint.html">Least Surprised</a> comic strips. So: well done! </p><p> With gallant help from gaal, we brought the failing subtests down to less than 200 -- one more day's work and it'd be releasable. Several weird bugs got fixed today, including the one that rendered <a href="http://www.nntp.perl.org/group/perl.perl6.language/23340"> <code>say {1}.()</code> </a> into <code>(say{1}).()</code>. Oops. </p><p> Also, the Perl5 and JS backend generators are now installed with Pugs, so <code>pugs -BPerl5</code> and <code>pugs -BJS</code> should run in the PxPerl binaries for 6.2.10, in addition to the PIR backend. I'm glad to see that the two stand-alone backends are in a good shape to become the highlight of this release. </p><p> Gaal also made all I/O errors catchable with <code>try{}</code>, thanks to a new<code>guardIO</code> lifter that promotes IO errors into <code>fail</code> in the Eval monad. </p><p> Tomorrow will be mostly about tidying up for the release. geoffb updated the <a href="http://svn.openfoundry.org/pugs/STATUS">STATUS</a> file extensively, so that leaves some changelogging and cabalization. </p><p> Oh, and an unfortunate news: TSa <a href="http://www.nntp.perl.org/group/perl.perl6.language/23346">bowed out</a> from the p6l mailing list, ironically at the same time as I refined the 6.2831 milestone into <em>Type system and linking</em>. I'm grateful to him for keeping up discussions about types, as well as referring me to various useful papers. Hopefully we'd indeed make Perl 6 the <em>artige Sprache</em> -- language of kindness -- as he wishes. </p><p> See you tomorrow!<nobr> <wbr></nobr>:)</p> autrijus 2005-10-05T23:07:21+00:00 perl6 Day 249 (r7292): Toward 6.2.10. http://use.perl.org/~autrijus/journal/27018?from=rss I'm finally setting the land in order, with aid from a richly alive #perl6. Together we fixed and TODO'ed some 400+ failed subtests today, with about the same number to go tomorrow, before we can release 6.2.10 in good conscience. <p> Happily, leo has become a #perl6 resident; with his help, we regained compatibility with Parrot 0.3.0's new calling conventions, and rules support via PGE again works. The new calling conventions are much saner; chip/leo have done a wonderful job. They are working on named parameters, lexical pads and variable-sized register frames for 0.3.1, which could be the first Parrot that Pugs can seriously target to. </p><p> Talked with Stevan about MM2, and we both agreed that Ruby-style singleton classes -- I mean <em>eigenclasses</em> -- is a saner way than this arbitrary distinction of class methods and instance methods. The user-visible API (aka metaobject protocol) would remain the same, but the internal dispatcher would be much easier to reason about. </p><p> After fixing the aforementioned arbitrary dispatch in the default runcore, brentdax's <a href="http://svn.openfoundry.org/pugs/ext/Cipher/">Cipher</a> suite passed all tests. It's a nice demonstration of multi-paradigmic module API; it supports functional, OO and procedural modes of operation. </p><p> Following yesterday's <a href="http://use.perl.org/~jesse/journal/26998">Parrot Sketch</a> (which finally appeared on <a href="http://planetsix.perl-foundation.org/">Planet Six</a>), nothingmuch volunteered to parse the rules tests into specification-based <a href="http://search.cpan.org/dist/Test-Base/">Test::Base</a> tests, so we can move them all into the Parrot tree where it belongs. </p><p> So, things are looking good for 6.2.10; we still need to solve installation for <code>perl5/</code>, and I'd like to integrate <a href="http://svn.openfoundry.org/pugs/Pugs.cabal">Pugs.cabal</a> for libpugs.o support as well. </p><p> After 6.2.10, the push for 6.28.0 will be done roughly by taking the PIL compilation backend, write a new container/metamodel runcore in Haskell to make sure it works correctly, improve the intermediate language until it hits what we needs for PIL2, and adjust js/p5/parrot backend accordingly. </p><p> Two months is an extremely long period between two releases; thanks for all lambdacamels for getting it into a fine shape, largely in my absence. It looks like <b>-O<em>fun</em> </b> is a worthwhile optimization after all: I'm happy to rejoin the fun, and even happier to see new committers around. geoffb promised to capture some related discussions in his <a href="http://www.oreillynet.com/pub/au/2333">weblog</a> tomorrow; I'm looking forward to see it. Ciao!</p> autrijus 2005-10-04T23:01:05+00:00 perl6 Day 246: Travelling. http://use.perl.org/~autrijus/journal/26962?from=rss Finally got some semblance of internet access now, and I'm ready to crash, so more detailed journal and commits will need to wait till tomorrow. <p> On the road I studied <a href="http://www.cs.uu.nl/wiki/Ehc/WebHome">EHC</a> and its way of using attribute grammars to illustrate separate concerns of compiler aspects is commendable. Haskell's type classes can implement synthethized (upward) attributes easily, but inherited (downward) attributes require a reverse-case, and AGs seem to be a better way to write them. </p><p> I also started coding Pugs.Class.Chaos, Pugs.Class.Pneuma, and the rest of the metamodel bootstrap. Doing this has made the migration plan somewhat clearer -- instead of migrating the internal language, the compiler <em>and</em> the runcore in a swift run, I'll instead realize the object runcore in a more modular manner, and replace upstream components as I go. More details tomorrow...</p> autrijus 2005-10-01T21:19:10+00:00 perl6 Day 245: Haskell Workshop. http://use.perl.org/~autrijus/journal/26953?from=rss Today's workshop has been a blast. David Roundy's darcs talk covered many challenges and advantages in using Haskell to develop a real-world application; he even mentioned <a href="http://svk.elixus.org/">SVK</a> once, in a positive light. Among other cool tricks, he employed interleave IO to separate program logic with I/O parts. I have used that trick in OpenAFP, but I'm beginning to see that has wider applications as a Pugs/Perl6 idiom -- <em>AOP with Lazy Lists</em>, if you will. <p> The <a href="http://haskell.org/cabal/">Cabal/Hackage</a> system (the equivalent of Module::Build/CPAN) generated much interest. Discussions centered around how to incite <em>spotaneous mutual goodwill</em> using social software frameworks, which is imho the key part of the CPAN cultural mechanism. </p><p> I'm glad to hear that the huge GHC distribution will be broken apart into various packages, to promote the sense of community library ownership. In the future, the GHC core will be minimal, just enough to run Cabal to install packages -- Perl5 porters have bounced this idea for quite some time now, and it's nice to see it happen here too. In addition, the Haskell people are also reducing the committer-bit deadlock, by adopting decentralized darcs repositories as the norm, so a change of maintainership is simply a URL redirection apart. </p><p> Another focal point is <a href="http://haskell.org/hawiki/hIDE">hIDE</a>, a Haskell development environment coded in Haskell, using the GHC bindings and build structures developed in the Visual Haskell effort. The choice of <a href="http://www.cse.unsw.edu.au/~dons/yi.html">Yi</a> as the editor component is particularly interesting -- it can dynamically load and rebind plugins, including the editor core itself, preserving the editor state (undo history/workspaces) without requiring a restart like Ecplise does. I suggested to dons that we should integrate the bootloader with GHC/Cabal, so <em>all</em> Haskell applications compiled this way can be code-swapped on the fly, even by <code>eval</code>'ing code from the user. I like dynamic languages with static typing... </p><p> I helped the library effort by polishing dons's <a href="http://www.cse.unsw.edu.au/~dons/fps.html">Data.FastPackedString module</a>, so it can subsume the old Data.PackedString implementation. The new string module is very fast and supports FFI, gzip and mmap natively. It is already used in the new PIL runtime; once it's merged into GHC core, it should give string manipulation-heavy programs a nice speed boost. </p><p> Hacking of GHC core continued. Pairing with wolfgang, the new <a href="http://icfpc.plt-scheme.org/">ICFP 2005 contest</a> champion, is very exciting and fruitful. We reasoned out how to support record updators for existentially-quantified GADT types, which is starting to dangerously resemble ML-style modules. </p><p> Also, from discussion with oleg and ccshan, I learned that GHC is actually well-equipped to natively support delimited continuations in the runtime. If implemented, Pugs's Haskell runtime can do away with the space-intensive ContT monad transformer thunks, and get a massive speed boost without changing a line of code. simonmar showed me the GHC runtime scheduler, and indeed there seem to be native support in the form of thunk-capturing asynchronous exceptions (which will incidentally give native support for the Perl6 <code>$!.resume</code>). Using a similar mechanism, we can also get a stack trace -- easily the #1 requested debug feature -- from fatal errors, at least when compiled for profiling. </p><p> Whew. That's a lot of hacking. Tomorrow I'll go back coding in MM2 and full Cabal support, and investigate full continuations on top of Perl5 VM. Stay tuned!</p> autrijus 2005-09-30T22:21:14+00:00 perl6 Day 244: Hacking GHC. http://use.perl.org/~autrijus/journal/26942?from=rss Continuing yesterday's work, today I got seriously addicted in GHC core hackery, skipping the entire Curry workshop. It was a real pleasure pairing with <a href="http://research.microsoft.com/~simonpj/">spj</a> on this. He reminded me of lwall -- both have an obsession on providing useful feedback to programmer, strong intuition on how language features intersect, and above all a deep enthusiasm to their respective languages. <p> Thanks to spj's continuous guidance, I hacked in support for existential record types on both vanilla and GADT types, which allows us to write:</p><blockquote><div><p> <tt>data Counter public = forall this. New<br>&nbsp; &nbsp; { self&nbsp; &nbsp;:: this<br>&nbsp; &nbsp; , inc&nbsp; &nbsp;<nobr> <wbr></nobr>:: this -&gt; this<br>&nbsp; &nbsp; , output<nobr> <wbr></nobr>:: this -&gt; IO ()<br>&nbsp; &nbsp; , tag&nbsp; &nbsp;<nobr> <wbr></nobr>:: public<br>&nbsp; &nbsp; }</tt></p></div> </blockquote><p>The <code>tag</code> function is well-typed as <code>Counter public -&gt; public</code>; the other three fields hides the real implementation from the <code>Counter</code> data type, so one can have a counter using Int, another using String, and have both be of the same type. </p><p> This representation is quite close to how encapsulation works in OO langauges, and the feedback from #haskell has been very positive. Additionally, the soundness of the GADT/Labels treatment passed scrunity by Oleg today, which made me feel much safer. </p><p> Of course, any attempt to use the three private fields as normal functions raises a compile-time error that advises the use of pattern-matching syntax instead. Also, in the GADT form, the <code>forall this</code> may be omitted to improve readability. </p><p> While I was madly hacking away, <a href="http://en.wikipedia.org/wiki/Brendan_Eich">brendan</a> passed by, and graciously accepted a Pugs T-Shirt from me. We talked about many things -- I'm very excited to hear that they are considering to adopt Rhino's continuation engine for SpiderMonkey (which will make Perl6-on-JavaScript insanely faster), and that the XUL scripting is proceeding well. They would like to use user's system python/perl/ruby/etc if possible, but that complicates the versioning problem. </p><p> Inevitably, the topic of shared runtime came up, and it seems that Mono's RAND patent position is still not yet very satisfatory. Parrot has matured a bit since two years ago when brendan checked it out, so I filled him on some recent development. With 0.3.0 out in a couple days, we can finally start targetting Parrot again -- hopefully the long wait will be proven worthwhile. </p><p> Oh, do check out <a href="http://www.oreillynet.com/pub/wlg/7928?CMP=OTC-BD0016219291">geoffb's writeup</a> of his musings on #perl6; it's a nice survey of some of the good ideas from other language that are finding their way into Perl6. </p><p> After yesterday's discovery of <a href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/ilxGen/">ILX codegen</a>, spj pointed out that there is a more robust <a href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/javaGen/">Java codegen</a> on the same directory. Targetting JVM suddenly looks more attractive too... </p><p> All in all, I think my time on hacking GHC core is well-spent; I learned a lot of Haskell idioms that should make Pugs code cleaner (such as the <code>case x of DataCon {} -&gt;<nobr> <wbr></nobr>...</code> syntax that works even on non-record types), and about complexity management of a large real-world language implementation -- i.e., what makes it to evolve extremely fast, despite a relatively small core team and contributor base, and an utterly broken issue-tracking system. RT-powered bugs.haskell.org seems like a good idea... </p><p> Tomorrow is the Haskell workshop, the final day and highlight of this conference. See you!</p> autrijus 2005-09-29T21:39:34+00:00 perl6 Day 233: Reports from ICFP! http://use.perl.org/~autrijus/journal/26921?from=rss The main ICFP conference session concluded today, so I'm finally getting a tiny slice of time to write down what I've been doing. <p> I enjoyed handing out Perl6/Timeline T-shirts to various lambdafolks, including bpierce (author of TaPL), spj (author of GHC), as well as several cool hackers from #haskell. At any time in the conference hall, there was always someone with a Pugs shirt in sight, leading to many interesting discussions and opportunities to join forces. </p><p> I spent much time hacking with the GHC core team (spj and simonmar, also known as "Simon and Simon"), to get my current #1 feature request -- GADT with record types -- into GHC. Among Haskell people, GADTs are all the rage this year; see <a href="http://svn.openfoundry.org/pugs/docs/notes/recursive_polymorphism_and_type_inference">luqui's notes</a> for a short introduction from Perl6's perspective. </p><p> During the YAPC::NA 2005 Toronto hackathon, I presented the then-brand-new PIL1 data structure to @Larry, using GHC's then-brand-new GADT syntax:</p><blockquote><div><p> <tt>data PIL a where<br>&nbsp; &nbsp; PCode&nbsp; &nbsp; &nbsp; &nbsp;:: SubType -&gt; [TParam] -&gt; PIL [Stmt] -&gt; PIL Expression<br>&nbsp; &nbsp; PBind&nbsp; &nbsp; &nbsp; &nbsp;:: [PIL LValue] -&gt; PIL Expression -&gt; PIL LValue<br>&nbsp; &nbsp; PAssign&nbsp; &nbsp; &nbsp;:: [PIL LValue] -&gt; PIL Expression -&gt; PIL LValue<br>&nbsp; &nbsp; --<nobr> <wbr></nobr>...etc...</tt></p></div> </blockquote><p>luqui looked at it and asked quite innocently: "Why are the arguments not labelled, such as 'lhs' for 'PAssign'?" -- To which lwall said, half-jokingly: "Because autrijus is a lazy bastard." </p><p> However, the real reason was because GHC's extended Haskell syntax only allowed positional argument types for GADT. To name them with the <em>record syntax</em>, we'd need to go back to the vanilla data types, and forgo the ability to encode type information using the constructor's return type (as demonstrated in <code>PIL Expression</code> and <code>PIL LValue</code> above). </p><p> A month later, I diligently re-encoded the structure using vanilla record types, so we can export them into hash-based Perl (and JSON) data structures, instead of array-based ones. This significantly improved the readability of iblech's PIL2JS code, but the Haskell data declaration became 3 times longer, because each GADT variant needs to be re-encoded into vanilla data types. </p><p> Ever since then, I was hoping that GHC may one day remedy this by allowing GADTs and record syntax to play together. When I met spj in ICFP, he was gladly surprised that I'm eager to hack GHC to make it happen. After bouncing several design ideas, we settled on this syntax:</p><blockquote><div><p> <tt>data PIL a where<br>&nbsp; &nbsp; PCode&nbsp; &nbsp;{ typ<nobr> <wbr></nobr>:: SubType, params<nobr> <wbr></nobr>:: [TParam], body<nobr> <wbr></nobr>:: PIL [Stmt] }<br>&nbsp; &nbsp; &nbsp; &nbsp;<nobr> <wbr></nobr>:: PIL Expression<br>&nbsp; &nbsp; PBind&nbsp; &nbsp;{ lhs<nobr> <wbr></nobr>:: [PIL LValue], rhs<nobr> <wbr></nobr>:: PIL Expression }<br>&nbsp; &nbsp; &nbsp; &nbsp;<nobr> <wbr></nobr>:: PIL LValue<br>&nbsp; &nbsp; PAssign { lhs<nobr> <wbr></nobr>:: [PIL LValue], rhs<nobr> <wbr></nobr>:: PIL Expression }<br>&nbsp; &nbsp; &nbsp; &nbsp;<nobr> <wbr></nobr>:: PIL LValue<br>&nbsp; &nbsp; --<nobr> <wbr></nobr>...etc...</tt></p></div> </blockquote><p>The neat thing is that <code>PBind</code> and <code>PAssign</code> can share the <code>lhs</code> and <code>rhs</code> labels, as long as their return value <code>PIL LValue</code> stays the same. </p><p> During the reception, spj was kind enough to guide me through the GHC core to unify the two data type definitions together back. The next day, simonmar walked me through the <a href="http://haskell.org/happy/">Happy</a> parser to get the new syntax recognized, and today spj showed me how the GHC typechecker works. All there's left is installing the labels as record selectors, and the upcoming GHC 6.6 will have a nice feature to fit Pugs's needs. Hacking GHC is evidently not as difficult as I feared!<nobr> <wbr></nobr>:-) </p><p> Talking about GADTs, I was also involved with the crazy project of encoding the <a href="http://darcs.net/">Darcs</a> patch algebra into the GADT type system, letting the compiler catch entire classes of common logic errors in darcs, bringing us dagerously close to the ideal of proof-carrying code. </p><p> Two days ago, when droundy told me this idea, I was very excited, started prototyping it, then promptly ran into errors on existential types. Heffalump took my laptop and shuffled it with Igloo, arriving at something that seemed to compile, which evolved into an embedded DSL for patches. After today's conference sessions, a dozen darcs hackers gathered together, learned about the recent developments of the patch theory, then worked on the GADT encoding. The hacking session was quite successful -- we didn't run into any showstoppers, much to everybody's surprise -- and I visiolized the whiteboard into this <a href="http://perlcabal.org/~autrijus/darcs-gadt.png">diagram</a>. </p><p> On the Pugs backend front, I learned from simonmar the existence of the ILX emitter library, hiding in a forgotten corner of GHC source tree. This enables us to emit pre-CLR-2.0 MSIL code that could run on Mono, under a 3-clause BSD license. Targetting CLR suddenly looks more attractive... </p><p> I also learned how to generate native machine code straight from C--, using the GHC API distributed as part of Lemmih's <a href="http://scannedinavian.org/~lemmih/ghc-api">ghc-api</a> Cabal package. </p><p> Speaking of Cabal, I learned from SyntaxNinja about the design of the Cabal/Hackage system, which is the Module::Build/CPAN equivalent for Haskell. We shared our experiences, and he helped me setting up the basic Cabal build rules for Pugs. With Cabal support, Pugs's Makefile.PL would only need to care about the Perl parts in the source tree, and we can finally get a libPugs to link with pugscc and other programs -- Inline::GHC is definitely on the radar, and the idea of using Perl6 to script the Haskell IDE (hIDE) is also gaining some traction. </p><p> Compiling with continuations, another pet interest of mine, also got a boost from ICFP. The <a href="http://www.cs.brown.edu/~sk/Publications/Papers/Published/pcmkf-cont-from-gen-stack-insp/">Generalized Stack Inspection</a> talk outlined how to use vanilla <code>try/catch</code> mechanism to implement full continuations, which is much more efficient than the regular trampolining approach as used in Pugs's JavaScript backend, since only people who actually use full continuations need to pay the cost for <code>catch</code>. Their technique operates on the ANF form, which seems to be a good low-level intermediate form for Pugs. </p><p> Interestingly, the paper went as far as saying that Parrot might have made a suboptimal choice in paying the full cost of going full-CPS, since we could emulate full continuations using exception handling efficiently. They gave concrete implementations in CLR and JVM -- we'll see if this result can carry over to Perl5 and JavaScript runtimes. </p><p> The invited talk of the first day tackled impredicative type inferencing, a long-standing problem in inferring types for a rich system such as Perl6. I had much trouble grokking the <em>Wobbly Type</em> idea of spj's, so I was much delighted to see that fpottier gave a very intuitive treatment of splitting the user-annotation-driven phase and the complete inferencing phase apart. </p><p> Oh, the ICFP contest. Haskell won again, which came at no surprise, but the Dylan Hacker team made another strong showing. From the brief investigation, I think Dylan is even closer to the "Perl 6 without advertisement" mark than Ruby, largely due to its incremental soft typing system, where one can start rapid prototyping with full dynamism, then generate more efficient and robust C code by adding type annotations. </p><p> Tomorrow is the Curry workshop, then the Haskell workshop on the day after. After that I'll get two weeks of Pugs hacking time. I can barely wait to apply those new techniques, tools and thoughts into Pugs!</p> autrijus 2005-09-28T21:28:18+00:00 perl6