[Bps-public-commit] r18021 - in Lorzy/trunk/lib/Lorzy: Expression Lambda

clkao at bestpractical.com clkao at bestpractical.com
Thu Jan 29 06:42:40 EST 2009


Author: clkao
Date: Thu Jan 29 06:42:39 2009
New Revision: 18021

Modified:
   Lorzy/trunk/lib/Lorzy/Evaluator.pm
   Lorzy/trunk/lib/Lorzy/Expression/Symbol.pm
   Lorzy/trunk/lib/Lorzy/Lambda/Native.pm

Log:
refactor evaluated_result and make lambda::native work with
non-expression arguments.


Modified: Lorzy/trunk/lib/Lorzy/Evaluator.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy/Evaluator.pm	(original)
+++ Lorzy/trunk/lib/Lorzy/Evaluator.pm	Thu Jan 29 06:42:39 2009
@@ -4,6 +4,7 @@
 
 use Lorzy::EvaluatorResult;
 use Lorzy::Expression;
+use Lorzy::Lambda::Native;
 use Params::Validate qw/validate validate_pos HASHREF/;
 use UNIVERSAL::require;
 
@@ -184,6 +185,15 @@
     };
 }
 
+sub evaluated_result {
+    my ($self, $exp) = @_;
+
+    ref($exp) && $exp->can('meta') && $exp->meta->does_role('Lorzy::Evaluatable')
+         ? $exp->evaluate($self)
+         : $exp; # XXX: figure out evaluation order here
+
+}
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 

Modified: Lorzy/trunk/lib/Lorzy/Expression/Symbol.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy/Expression/Symbol.pm	(original)
+++ Lorzy/trunk/lib/Lorzy/Expression/Symbol.pm	Thu Jan 29 06:42:39 2009
@@ -26,9 +26,7 @@
     my $symbol = $self->{'args'}->{'symbol'}->evaluate($eval);
     my $result = $eval->resolve_symbol_name($symbol);
 
-    return ref($result) && $result->can('meta') && $result->meta->does_role('Lorzy::Evaluatable')
-         ? $result->evaluate($eval)
-         : $result; # XXX: figure out evaluation order here
+    return $eval->evaluated_result($result);
 }
 
 __PACKAGE__->meta->make_immutable;

Modified: Lorzy/trunk/lib/Lorzy/Lambda/Native.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy/Lambda/Native.pm	(original)
+++ Lorzy/trunk/lib/Lorzy/Lambda/Native.pm	Thu Jan 29 06:42:39 2009
@@ -10,7 +10,8 @@
 sub apply {
     my ($self, $evaluator, $args) = @_;
     $self->validate_args_or_die($args);
-    my %args = map { $_ => $args->{$_}->evaluate($evaluator) } keys %$args;
+    my %args = map { $_ => $evaluator->evaluated_result($args->{$_}) }
+        keys %$args;
     my $r = $self->body->(\%args);
     return $r;
 }



More information about the Bps-public-commit mailing list