[LA.pm] Parallel::Simple

Ofer Nave ofer at netapt.com
Sun Feb 27 13:21:17 PST 2005


Thanks for the feedback.  Comments inline:

On Sat, 26 Feb 2005, Kevin Scaldeferri wrote:

> Here are a couple quick comments I had.
> 
> First, I think it's almost always good to 'use warnings'.

You're right.  I always use -w in my scripts, so I take it for granted 
that my code always runs with warnings on.  But in the context of a CPAN 
module, that is a good suggestion.  Done.

> You probably ought to initialize $error and $return_values.  Otherwise 
> you might have some problems if someone did something odd like run()ing 

No reason to.  I would only initiliaze them to undef to signify that they 
have not yet been defined, but perl does this to new variables 
automatically.

> no processes then checking the results.  You might also want to 
> explicitly reset those globals at the start of run() as well.

Now, THIS is a bona-fide bug.  I could have sworn I was doing that at some 
point, but I guess the code got lost in the chaos of development.  I'll 
add that back in.

> For that matter, there may be some other things that don't work out 
> right if the number of code refs to run is 0.

You know, I've been thinking about what's the most perlish way to handle 0 
arguments.  It's almost like a no-op.  I suppose I should test for it and 
return true right away, since the philosophy of the module is true unless 
something has gone wrong - and nothing can go wrong with a no-op.

> I also have an objection to the terminology you are using in the code 
> and documentation.  You refer to "blocks" when I think that you really 
> mean "code references".

Code references would be the most correct name, perhaps, but I belive code 
blocks is not incorrect (subtle difference), and is a much more expressive 
word.  I like the terminology to invoke a visual sense of the concepts 
that are being represented, and when I call prun, I don't visual passing 
references, I visals blocks of code running in parallel.

I apologize for the outdated page references - I've still got the 2nd 
edition of Programming Perl:

[page 97]

"A sequence of statements that defines a scope is called a block."

"When we mean a block with braces, we'll use the term BLOCK."

[page 111]

"To define an anonymous subroutine or closure at run-time, use a statement 
like:

	$subref = sub BLOCK;"

I guess we could compromise on calling the passed-in values references to 
code blocks.  :)

> > After some polishing up, I'll write some tests for it and package it 
> > up in
> > the standard CPAN module format before uploading it.
> 
> tsk tsk... you should write your tests first!

Well, writing tests is going to involve studying tests for one or two 
popular/standard CPAN modules to get a feel for the style and tools, and 
then actually writing my own tests.  That's a lot of time invested for a 
module that might change drasticly in the next few days in response to 
feedback.

Rest assured I will have tests for it before it's shipped.

(Besides, I always test my code to some degree as I write it.  Just not as 
formal 'tests'.)

> Hope this is helpful,

It is!

-ofer



More information about the Losangeles-pm mailing list