From: ChrisO Date: 2004-09-16T08:04:51+09:00 Subject: Re: Ex-Perl coders: Howz it feel to convert to Ruby? Phil Tomson wrote: > In article <8x%1d.2604$Qv5.529@newssvr33.news.prodigy.com>, > Chris wrote: > >>(4) Each language has it's own strengths. IMO one of Perl's strengths >>is the simplicity and consistency of it's parameter passing: >> >>sub shell { >> >> my @output; >> for (@_) { push @output, `$_` } >> chomp( @output ); >> return wantarray ? @output : \@output; >> >>} >> > > > Actually, I think this is one of the _worst_ things about Perl and it was > one of those nagging little annoyances that when added up finally led me > to seek out alternatives. The problem with the way parameters are passed > to subroutines in Perl is that you can't tell from a glance how many > params are supposed to be passed into the subroutine and you have no > information about what the params are. You've got to look down through > the subroutine code to see if there's a 'shift @_' lurking somewhere in > the code (for the uninitiated, you pass params to Perl subroutines via the > '@_' global list; you have to 'manually' shift the params off of that list > - blech! ) > An incredibly interesting point of view though your justification for it is somewhat understandable. Pathological mistakes can occur this way for those that use this, what I would call an incredibly nice feature, in an undisciplined way. I'm quite disciplined about spiking out my arguments in Perl at the top of a subroutine. I think your dislike perhaps has been fueled by people that write subroutines in a "hackish" sort of way. (I would imagine "hacking" Ruby is just as possible to accomplish.) But aside from the undisciplined uses you've pointed out as reason for eshewing this in Perl, I have to wholy stand by the amazing power this feature brings. It far outweighs the negatives. It's one of the "genius" things about Perl. (Always educational, however, to get someone else's opposite point of view, as you have offered.) And to bring this Perl discussion back on topic, in line with your dislike of this "feature" in Perl, am I not correct in understanding that in Ruby, one can create methods on the fly in a class? How is this that much different (conceptually) than unspecified parameters in a Perl subroutine? How do you know what methods are there (aside from using the inspection methods available to every class [unless I am mistaken in this regard]). -ceo