2010-05-20

Perlesque's Class Declarations Obtained Custom Constructors and Single Inheritance

Tonight I completed the "next tasks" from this mornng's post: constructors (including ones with parameters, of course) for CLR classes defined in Perlesque, and single inheritance of classes.  So the following Perlesque code is valid:

class Foo {
  has int $a;
  method new (--> Foo) {
    say("made a Foo");
  }
}
class Bar is Foo {
  has int $b;
  method Baz (--> int) {
    say("a is " ~ (self.a ~ (" and b is " ~ self.b)));
    return 1;
  }
  method new (int $a, int $b --> Bar) {
    say("made a Bar with a == " ~ ($a ~ (" and b == " ~ $b)));
    self.a = $a;
    self.b = $b; 
  }
}
my $bar = Bar.new(4, 6);
$bar.a += 7;
$bar.b *= 3;
$bar.Baz();


and the output is:
made a Foo
made a Bar with a == 4 and b == 6
a is 11 and b is 18

Next, I'm going to coordinate with sorear & pmurias on #perl6 to get a handle on Cursor/LazyMap/STD/viv, with the eventual (but hopefully soon!) goal of either extending Sprixel's grammar engine to cover all of Cursor's capabilities or manually porting Cursor to perlesque (which I guess is tractable), so that viv can emit STD's parse tree of itself to perlesque, using emit_perlesque.

Then STD is running on the CLR, and it's all downhill from there.... where by "downhill" I mean the gravity is strong enough to pull us all the way down to the bottom of the hill, but there are a few PetaNewtons of friction/obstacles the gravity will have to overcome between here and there.  But at least we'll be able to see the bottom.

No comments:

Post a Comment