On Mon, 16 May 2005 01:05:28 +0900 Joel Rees <[EMAIL PROTECTED]> wrote:
> The bug/feature is that you can't declare variables unless you > declare them either "local" (which is usually not what you want) or > "my" (which _is_ what you usually want). The buggy aspects of this > feature are mostly relieved by "use strict" and other pragma. > > (Do NOT forget to "use strict" !) I am not commenting on any buggy aspects of this feature, I am commenting on this feature itself. Use strict doesn't change the scoping rules of perl, having to use "my" at all is the problem, its backwards and stupid when variables should be assumed to be lexical scope. > Perl also provides for passing parameters as a hash instead of an > array. The good part of that is that if you pass red, green, and > blue, you don't have to remember whether red, green, or blue came > first in the list. The bad part of this is left as an exercise for > the reader. (I'd give an example, but my head is so full of Java > these days I couldn't guarantee getting the syntax right.) You don't have to remember the order that args are passed with normal languages where functions take named args either. > > With perl you can > > only pass an array as a reference, if you want a second array you > > have to copy the one passed as a reference manually in the sub. > > Not exactly true, although getting the hang of passing arrays can > take some time. (And reading code that does it the right way can be > something of an adventure, especially for programmers who are mostly > experienced in descendants of Algol.) I'm no perl expert, I'm just going by the perl documentation here where it says that you can only pass arrays and hashes as references. Then you need to make a new copy of that array or hash yourself inside the sub if you don't want to be changing the original one. I'm not saying its that big a deal, its just inflexible and a waste of programmer time. > > course, if all you want is an array of args, languages that let you > > declare arguments to functions can give you that just fine. Perl is > > all about being flexible and saving programmer time, yet something > > basic > > like functions is implimented in an inflexible way that requires > > programmers to spend extra time checking args. Declaring args is > > both more flexible, and a time saver. > > Not true. The problem is not inflexibility, but once again too much > flexibity. Of the several ways to solve the problems of passing > parameters in perl, the one that is closest to traditional procedure > parameter lists is perhaps a bit too spare in its requirements. Yes true, you can handle every arg passing situation perl is capable of in a language using named args, as well as situations perl doesn't handle without you doing it yourself in the first couple lines of your sub. Therefore named args is more flexible, and saves programmer time. Notice that perl 6 is supposed to be fixing some of this stuff, so its obviously not just me that thinks there's problems here. Adam