Ashley Winters <[EMAIL PROTECTED]> writes: >> <grin> Patches welcome. > > Excellent... > > Forgive any formatting errors, I have mail issues.
Thanks, applying. With a few caveats. > @@ -62,6 +62,7 @@ > class SchemePair is SchemeExpr { > my $nil //= class is SchemeExpr { > method is_nil {1} > + method is_pair {0} > method car { fail Exception: > msg => "car: expects argument of type <pair>, given > ()" } > method cdr { fail Exception: That change isn't necessary. If you look you'll see that the anonymous class of which $nil is the only instance is a subclass of SchemeExpr, not SchemePair. > @@ -77,12 +78,13 @@ > method car { .value.key } > method cdr { .value.value } > method is_pair { 1 } > + method is_nil { 0 } SchemeExpr's AUTOLOAD handles that automagically. > method AUTOLOAD { > .NEXT::AUTOLOAD unless $AUTOLOAD =~ /:?c([ad]+)r$/; > - my @ops = reverse split '', $1; > - my $val = $_[0]; > + my @ops = reverse split '', $1; # $1? Apocalypse 5... > + my $val = @_[0]; YARGH! I thought I'd got rid of all those 5isms. > > method new_scope($self:) { ref($self).new(__parent__ => $self) } > > - method bind_primitive($name, &func) { > - .bind(SchemeSymbol.new($name), > - SchemePrimitive.new( $name => &func )); > + method bind_primitive(PAIR @primitives) { > + for @primitives -> $primitive { > + .bind(SchemeSymbol.new($primitive.key), > + SchemePrimitive.new( $primitive )); Hmm... does that declaration syntax work? I really hope so 'cos it's lovely. > } > > my method parent { .{__parent__} } > > method set($self: SchemeSymbol $key, SchemeExpr $value) { > given .exists($key) { > - when defined { .value($value) } > + when defined { .{key} = $value } D'oh. Should be C<.{$key}> thought. > - '+' => $expr, $context -> { > + '+' => -> $expr, $context { Oops. C<sub operator:&lambda { -> *@_ }> anyone? -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen?