May 2008 Archives
The Perl 6 design team met by phone on 07 May 2008. Larry, Allison, Patrick, Will, Jerry, Nicholas, Jesse, and chromatic attended.
Allison:
- spent my time this week slicing and dicing the exceptions implementation
- replaced the old internals with the new system
- checked that in yesterday
- still a few failing tests in edge cases on the branch
- did more work on the Parrot Foundation
c:
- I own an acre of Mars, we could incorporate there
Allison:
- don't you own a cow in the Philippines?
c:
- yes, but that doesn't give me any governmental powers
Patrick:
- isn't that worth a lot?
c:
- the peso is improving against the dollar
Jesse:
- moving on...
Larry:
- clear bill of health from my medical reports
- hacking a lot against the standard grammar in my STD5 implementation
- lots of refactoring
- all of the various parameters that used to go through separately now go through as part of the Match object
- including the "fate" and whether we're peeking at the longest token set
- the longest token matcher works now
- I threw out my old mechanism for gathering Match objects
- it now creates the more-or-less correctly
- lots of grammar tweaks, as suggested by Mitchell Charity
- lots of refactoring of how logging works so that it doesn't always spew enormous quantities of information to the screen
- I can actually run the parser quite quickly now, for some definition of quickly that approximates 2000 characters per second
- matches symbols directly, rather than calling a rule, which is faster
- does the backoff now on longest token matching
- started refactoring the grammar on the assumption that I cna trust the longest token matcher
- no longer any
nofatrule - the longest token should match the fat arrow, if there is one
- started refactoring the quoting rules to parse as if they were sublanguages
- getting rid of extra rigamarole to recreate the other mechanism we already use for other languages
- working out the linkage for switching in and out of sublanguages
- how to get to the outer language from the inner language
- calling into pure Perl from closures in a regex
- or the host language if you're calling the regex from another language
- nailed down the available methods for Match objects in the specs
- giving a talk in Seattle on Friday at SPU
- flying to Japan on Saturday
Patrick:
- spent a lot of time teaching this past week
- cleared up now
- mostly I've answered questions on mailing lists and IRC
- I'm not always sure that I'm helpful, but I'm there
- yesterday I worked on trying to get a bunch of little small things here and there
- fixed up a few things in PCT internals
- today I'm bringing PGE up to date with some of the latest changes in S05
- these all help Rakudo and other languages in small ways
- trying to clean out my backlog and clean up a bunch of RT tickets
- I'll continue over the next couple of days
- and blogging about it as I go
Jerry:
- things are busy, mostly non-Parrot related stuff
- submitted a ticket that I hope Patrick can close today
Patrick:
- many languages depend on the old behavior, including Plumhead
- I'm not certain about some of them
Jerry:
- mostly otherwise answering questions on #parrot
- making sure that things are set up for the real work phase of GSoC
- making sure that students have their CLAs, if not commit bits
- astonished to see how much work Jonathan is getting done in just two funded days
- it's amazing to see how much a motivator money can be
- I'd like to see more of it, hint hint
c:
- working on closing as many open Parrot bugs as possible
- applying as many open patches as possible
- should be able to help on the concurrency branch soon
- otherwise preparing for the release
- going to check on received CLAs this week
Nicholas:
- found it curious that Perl 5.10 has the best
stateimplementation of any language - wanted to steal tests from another implementation
- had a discussion with Leon about SMOP
- there's no real description of how all of these implementations fit together
- Rakudo plus Parrot is a complete implementation
- SMOP and kp6 fit together nicely
Jesse:
- I started a wiki page on the Perl 6 wiki at Perl_6_Implementations
Patrick:
- I don't know that it says how things fit together
Jesse:
- I tried to encourage other people to contribute stuff
- didn't get much uptake
Nicholas:
- should we suggest to Daniel that he should help explain things?
Jesse:
- that's more likely to get people contributing to it
Will:
- there's definitely some confusion about it within the Grants Committee
Jerry:
- SMOP has the highest documentation-to-line-of-code ratio of any implementation
Patrick:
- it needs a good overview though
Nicholas:
- I'll ask Daniel to explain more
- especially its relationship to Parrot and Rakudo
Jerry:
- it sounds like it could be an alternate runcore for Perl 5 as well
Jesse:
- tried a few different things
- decided to write a test for Rakudo
- tried a simple arithmetic test pulled from Pugs
- found that Rakudo didn't implement a function specified in the S29 draft
- Patrick helped me write a couple of lines of code to implement it
- then discovered that fudge didn't support try blocks in a specific way
- Larry patched that
- then found that incrementing an undefined value didn't work in Rakudo
- that was the end of my day
- I still need to write up my findings
- how easy is it for someone without experience in Rakudo and its internals to pick things up and contribute something?
- more difficult than I thought it might be, but it's getting more doable
- it's important to understand how it might fail before trying to get people to do it
- then I started trying to play with MAD on the weekend
- found and fixed a bug in its XML
- refactored it such that you can run MAD's tests in the core if you add a copy of XML::Parser to the core
- it's not far enough yet, but it's a start
Nicholas:
- is it going to be difficult to restructure the Parrot foundation from 501(c)(3) to 501(c)(6)?
Allison:
- you can do pretty much the same thing
- sponsors are on the board in a c6
- they're only advisory in a c3
- the sponsors we've talked to are mostly only interested in getting regular status reports and the like
Jesse:
- is there any jumping around to transfer copyright to the new foundation?
Allison:
- we'll do a copyright assignment from the Perl Foundation to the Parrot Foundation
- all of the CLAs that went into the code up to the point of signover will be fine
- but we'll essentially copy the Perl Foundation CLA to a Parrot Foundation CLA
Will:
- do we need to contact committers who haven't signed a CLA?
Patrick:
- where does Rakudo fall?
Allison:
- still under the Perl Foundation
- it doesn't move at all
Will:
- do we want to split up the repository at that point?
Allison:
- eventually, we'll want to do so anyway
- it's not an urgent thing
Jerry:
- what would it take to version a Perl6Regex frontend to PGE?
- let grammars specify a version of the grammar
Patrick:
- I did that before by having a separate compiler
- you're talking about something a bit finer grained
- I don't want to do that
- as we get closer to 1.0, that'd be fine
- I already have enough to do keeping up with the latest versions
Will:
- I don't think we want to keep up old versions
Patrick:
- I don't mind sticking to our deprecation cycle
- I hadn't put the change from today into the deprecation list yet
- we'll get to it in a couple of weeks
Jerry:
- just trying to figure out how to push forward with changes to PGE without having to update every language in the repository
Patrick:
- freeze S05?
- not a great solution
Larry:
- I heard that
Patrick:
- the last few changes have been great
- I'm not really serious about that
Larry:
- some of them you even asked for
c:
- it's an advantage to have these languages in the repository
- we can update them
- but only if we can run the tests before and after and know that they pass
Will:
- we might consider removing languages with failing tests and no recent updates
- there are 17 grant proposals, some of them Perl 6-related
- please comment on the TPF blog
- it'll help
Jesse:
- blog.perlfoundation.org
I started out the day by looking through the RT queue for Rakudo. Two tickets were already dealt with, so I just closed those. Another was a bug report concerning assigning undef to typed variables. Doing:
my Int $x = undef;
Would give a type check failure. This is now resolved. Furthermore, if your type is a class name, then assigning undef at any point to it will result in it holding the protoobject for that class again. I also took a moment to post to Perl 6 Language to get some clarifications on what "my TypeName $x;" left $x being when $x was a role, subset type or a junction of types.
Last week I started getting grammars in place. I got so far as having the regex live in the correct namespaces, but that didn't make grammars at all class-like, which is how they should be. This week I set out to fix that. Grammars now get protoobjects too, which you can call .WHAT and so forth on. Furthermore, I got inheritance working and also smart-matching against a grammar, which runs it's TOP rule. Therefore you can now run the following example in Rakudo.
grammar Loads { regex Lots { \d+s } };
grammar Many is Loads { rule TOP { of } };
if "100s of 1000s" ~~ Many {
say $/; # 100s of 1000s
}
Having closed four RT tickets so far, I took a look through there to see what else there was. There was one that did most of what was needed to implement the .perl method on Junctions (which you can call, in theory anyway, on anything to get a Perl representation of it). I did the required fixes and applied it, but realized in the process that we were missing .perl for any of the really fundamental types, so I added it for Num, Int and Str.
With that done, I spent a little time on the S12 tests. I added fudge directives to get one of the that failed to parse to do so, and added an extra test. I plan to add much more here and flesh out the tests quite a bit over time.
Turning back to the OO support, I did some updates to the grammar that both brought us closer to STD.pm - the official grammar - and added the ability to parse a range of extra things. The first grammar changes were related to method calling. Normally you call a method just with ".", but private methods are called with "!". Additionally, there are ways to call sets of methods with quantifiers (.?, .+ and .*, with meanings analogous to those in regexes). Finally, I added the ability to scope declarations of routines too, so we can now parse lexical subs and private methods. I stubbed in conditionals for all of these cases that throw unimplemented exceptions, so people didn't use them expecting that because they parse, they will also work.
So, now there's a bunch of stubs in there for another bunch of OO features and, if nobody beats me to it, I'll be filling some of those out on my next Rakudo day, or maybe before then if time allows (though I'm moving apartment - and country - over the coming week, so I'm not expecting to have much time). A big thanks to Vienna.pm for funding today's work.
Today's work has been a mixture of refactoring and clean-ups that had been on the want list for a while, but just hadn't happened, as well as making some new things work.
First, the initial work I did on types attached them to variables, but what we really needed was a more general way to attach properties. Therefore, there is now a hash of properties instead, where we can stash other stuff.
Next up, I had based pairs on the Parrot Pair PMC, though as Patrick pointed out it's so far off being right for Perl 6 (for example, it's mutable, the Perl 6 one isn't) that we might as well just have our own. Dropping the Parrot Pair PMC and doing that took me all of ten minutes of work, and we get the semantics of pairs a bit more correct too. So that's much cleaner now.
A few days back, dakkar sent in a bug report regarding inheritance. It was almost correct code, but didn't work on Rakudo, since initialization of parent attributes was not yet implemented. I've now implemented this, and I'll borrow the example from the bug report to demonstrate it.
class Foo {
has $.x;
method boo { say $.x }
}
class Bar is Foo {
method set($v) { $.x = $v }
}
my Foo $u .= new(:x(5));
$u.boo; # 5
$u= Bar.new(Foo{ :x(12) }); # This is what now works
$u.boo; # 12
$u.set(9);
$u.boo; # 9
This is not some magical hacky syntax just to make constructors work; you can use it in the general case to associate some vivification data with a proto-object, which gives you a copy of it back with the data attached. It's a bit like currying the object instantiation. So after making the above work, it wasn't much more work to get the following working.
class Foo { has $.x }
my $foo42 = Foo{ :x(42) };
my $test = $foo42.new();
say $test.x; # 42
Note that the original Foo itself isn't changed. We'll have to revisit this again later, because the way I've done it now doesn't have the lazy semantics it's eventually meant to have. It makes the common use case work, though.
With some time spent on objects, I moved onto some improvements to regex stuff. The upshot of this is that you can now use grammar to group regexes into a namespace.
grammar Test {
regex Load { \d+s };
rule Loads { <Load> of <Load> };
}
if "100s of 1000s" ~~ Test::Loads { say "yes" }
yes
Note that this is just the start of grammars; inheritance doesn't yet work and you can't smart-match against them yet. It's a stop forward, though.
If you're an avid Rakudo follower, you'll have noted that regex, rule and token all (wrongly) did the same thing before today. I've fixed that too now (there was some behind the scenes work in being able to pass options to the compiler that will be useful elsewhere, as to users of the Parrot Compiler Toolkit in general). In a nutshell, token and rule don't backtrack, where as regex does, and additionally rule translates spaces to the
# Demonstrating :ratchet semantics (rule like token here).
regex WillBT { a*a }
token WontBT { a*a }
if "aaa" ~~ WillBT { say "yes" } else { say "no" }
yes
if "aaa" ~~ WontBT { say "yes" } else { say "no" }
no
# Demonstrating :sigspace semantics.
regex Test1 { \d \d };
rule Test2 { \d \d };
if "12" ~~ Test1 { say "yes" } else { say "no" }
yes
if "1 2" ~~ Test1 { say "yes" } else { say "no" }
no
if "12" ~~ Test2 { say "yes" } else { say "no" }
no
if "1 2" ~~ Test2 { say "yes" } else { say "no" }
yes
So, that's what got done today. I'd like to thank Vienna.pm for funding this work, and hope you'll have fun playing with it, breaking it and reporting bugs. :-)
First of all, before I dig into what my recent Rakudo hackings have been, I'd like to thank Vienna.pm for funding me to work on Rakudo. I will be working one full day a week on Rakudo from now on, at least for the next three months and, hopefully, longer. Today is the first day I'm working under this funding, so I'll be posting again later on today about what I got done. This post is just to update you on little bits that I've been doing, but didn't get written up yet.
First of all, you can now use the .= operator.
class Foo { }
my Foo $x .= new();
Here we call the 'new' method on $x, which we know is of type Foo thanks to the type declaration, and assign what it returns - namely, an instance of Foo - to $x. I did initially put this in a while ago, but it was a tad buggy and I wanted to get those worked out before posting it. That's been done, so happy playing. (And note you can use it in places other than declarations too.)
Additionally, some very basic multi-method dispatch based upon types is now in place. You can only use class names, not constraints or role names at the moment for the types, and certainly not more complex types than that. However, it's a start and allows us to run the following example.
class Thing {}
class Rock is Thing {}
class Paper is Thing {}
class Scissors is Thing {}
multi sub defeats(Thing $t1, Thing $t2) { 0 };
multi sub defeats(Paper $t1, Rock $t2) { 1 };
multi sub defeats(Rock $t1, Scissors $t2) { 1 };
multi sub defeats(Scissors $t1, Paper $t2) { 1 };
my $paper = Paper.new;
my $rock = Rock.new;
say defeats($paper, $rock); # 1
say defeats($rock, $paper); # 0
Finally, I put in a small optimization to avoid having to run some runtime type-checks when we can statically determine they're not needed. This should help performance a little.
