[Bps-public-commit] r13871 - in Lorzy/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 8 13:13:48 EDT 2008


Author: sartak
Date: Tue Jul  8 13:13:47 2008
New Revision: 13871

Modified:
   Lorzy/trunk/   (props changed)
   Lorzy/trunk/lib/Lorzy/FunctionArgument.pm
   Lorzy/trunk/lib/Lorzy/Lambda.pm

Log:
 r63849 at onn:  sartak | 2008-07-08 13:13:43 -0400
 Clean up FunctionArgument and Lambda


Modified: Lorzy/trunk/lib/Lorzy/FunctionArgument.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy/FunctionArgument.pm	(original)
+++ Lorzy/trunk/lib/Lorzy/FunctionArgument.pm	Tue Jul  8 13:13:47 2008
@@ -1,22 +1,19 @@
 package Lorzy::FunctionArgument;
 use Moose;
 
-
-
 has name => (
-    is => 'rw',
-    isa => 'Str'    
+    is  => 'rw',
+    isa => 'Str'
 );
 
-
 has type => (
-    is => 'rw',
-    isa => 'Str'# I want an enum of String, Number, Undef, Lorzy::Expression..what else?
+    is  => 'rw',
+    isa => 'Str', # I want an enum of String, Number, Undef, Lorzy::Expression..what else?
 );
 
 has description => (
-    is => 'rw',
+    is  => 'rw',
     isa => 'Str | Undef',
-    required => 0);
+);
 
 1;

Modified: Lorzy/trunk/lib/Lorzy/Lambda.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy/Lambda.pm	(original)
+++ Lorzy/trunk/lib/Lorzy/Lambda.pm	Tue Jul  8 13:13:47 2008
@@ -1,72 +1,69 @@
-
 package Lorzy::Lambda;
-use Moose; use MooseX::Params::Validate;
+use Moose;
+use MooseX::Params::Validate;
 
 with 'Lorzy::Block';
 
 has progn => (
-    is => 'ro',
-    isa => 'Lorzy::Expression::ProgN',
+    is      => 'ro',
+    isa     => 'Lorzy::Expression::ProgN',
     default => sub { Lorzy::Expression::ProgN->new },
-    handles => [qw(nodes)]
+    handles => [qw(nodes)],
 );
 
 has signature => (
-    is => 'rw',
+    is      => 'rw',
     default => sub { {} },
-    isa => 'HashRef[Lorzy::FunctionArgument]');
+    isa     => 'HashRef[Lorzy::FunctionArgument]',
+);
 
 sub check_args {
     my $self = shift;
     my $passed = shift; #reference to hash of provided args
     my $expected = $self->signature; # expected args
-    
-    
+
     my $missing = {};
     my $unwanted = {};
-    
-    my $fail =0;
+
+    my $fail = 0;
     foreach my $arg (keys %$passed) {
-            if  (!$expected->{$arg}) {
-            $unwanted->{$arg} =  "The caller passed $arg which we were not expecting" ;
-            };
+        if (!$expected->{$arg}) {
+            $unwanted->{$arg} = "The caller passed $arg which we were not expecting" ;
+        }
     }
-    foreach my $arg (keys %$expected) {
-                 if  (!$passed->{$arg}) {
 
-                $missing->{$arg} =  "The caller did not pass $arg which we require";
-                }
+    foreach my $arg (keys %$expected) {
+        if (!$passed->{$arg}) {
+            $missing->{$arg} =  "The caller did not pass $arg which we require";
+        }
     }
 
-    return $missing, $unwanted;
+    return ($missing, $unwanted);
 }
 
 sub validate_args_or_die {
     my $self = shift;
     my $args = shift;
-    my ( $missing, $unwanted ) = $self->check_args( $args);
-
-    if ( keys %$missing || keys %$unwanted ) {
-        die "Function signature mismatch \n".
-        (keys %$missing? "The following arguments were missing: " . join(", ", keys %$missing) ."\n" : ''),
-        (keys %$unwanted? "The following arguments were unwanted: " . join(", ", keys %$unwanted)."\n" : '');
+    my ($missing, $unwanted) = $self->check_args($args);
 
+    if (keys %$missing || keys %$unwanted) {
+        die "Function signature mismatch \n"
+          . (keys %$missing  ? "The following arguments were missing: " . join(", ", keys %$missing) ."\n" : '')
+          . (keys %$unwanted ? "The following arguments were unwanted: " . join(", ", keys %$unwanted)."\n" : '');
     }
-} 
+}
 
 sub apply {
     my ($self, $evaluator, $args) = @_;
 
     $self->validate_args_or_die($args);
 
-    $evaluator->enter_stack_frame( args => $args, block => $self );
+    $evaluator->enter_stack_frame(args => $args, block => $self);
     my $res = $self->progn->evaluate($evaluator);
 
-    $evaluator->leave_stack_frame(); 
+    $evaluator->leave_stack_frame;
     return $res;
-    #return $evaluator->result->value; 
-
-    
 }
 
 1;
+



More information about the Bps-public-commit mailing list