On Mar 1, 2004, at 3:59 AM, Gary Stainburn wrote:

Okay, I can do that simply enough, but could you elaborate on the reason
please.

Sure.


Subroutines may be called recursively. If a subroutine is called using
the "&" form, the argument list is optional, and if omitted, no @_
array is set up for the subroutine: the @_ array at the time of the
call is visible to subroutine instead. This is an efficiency mechanism
that new users may wish to avoid.


That's a quote from 'perldoc perlsub', which does a far better job of explaining these things than I could. It's worth a look.

2. I prefer $self->{_BLOCKS}= { }; to %{$self->{_BLOCKS}}=();. It's a
little less noisy.

I'm sure I tried that, along with a miriad of alternatives. I'll change the
code and see what happens. I agree about the noise, and also David's comment
about it being 'more correct'.

Just be sure to note that those are braces in my version, not parens. It works, trust me. ;)


3.  Just FYI, if you're trying to use a consistent case with something
like $dir=uc($dir);, lc() is usually preferable to uc().  Uppercase
isn't as consistent in some dialects, so it makes your code more
portable.

Interesting. I never new that. But then again I only speak Yorkshire.

But trains are a little more universal, so it pays to plan ahead and build good habits.


I'm not too found of mixing subroutines and methods, especially in the
same file. Why don't you turn them into class methods, instead. This
especially makes sense for things like debug(), which the other classes
can then call with Trainset->debug().

Wouldn't that confuse things regarding the %_DEBUG? I don't see the problem
with using subroutines within the class itself, although I could understand
it if the subs were used outside the class it was in.

I doubt it, no. In fact, I suspect it would be an improvement. If you have a:


my %_DEBUG; # lexical scoping makes this a class variable

in Trainset.pm that is setup will the needed information and provide a class method interface to it, it's a 100% solution that needs now other hashes or methods. That seems ideal to me.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to